Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Add gelf-php to `composer.json` either by running `composer require graylog2/gel

"require": {
// ...
"graylog2/gelf-php": "~1.5"
"graylog2/gelf-php": "^2.0"
// ...
}

Expand Down
6 changes: 3 additions & 3 deletions src/Gelf/Transport/HttpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
) {
parent::__construct();

if ($port == self::AUTO_SSL_PORT && $sslOptions === null) {
if ($port === self::AUTO_SSL_PORT && $sslOptions === null) {
$this->sslOptions = new SslOptions();
}

Expand All @@ -72,7 +72,7 @@ public static function fromUrl(string $url, ?SslOptions $sslOptions = null): sel
$parsed = parse_url($url);

// check it's a valid URL
if (false === $parsed || !isset($parsed['host']) || !isset($parsed['scheme'])) {
if (false === $parsed || !isset($parsed['host'], $parsed['scheme'])) {
throw new \InvalidArgumentException("$url is not a valid URL");
}

Expand All @@ -86,7 +86,7 @@ public static function fromUrl(string $url, ?SslOptions $sslOptions = null): sel
$defaults = ['port' => 80, 'path' => '', 'user' => null, 'pass' => ''];

// change some defaults for https
if ($scheme == 'https') {
if ($scheme === 'https') {
$sslOptions = $sslOptions ?: new SslOptions();
$defaults['port'] = 443;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gelf/Transport/KeepAliveRetryTransportWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class KeepAliveRetryTransportWrapper extends RetryTransportWrapper

public function __construct(HttpTransport $transport)
{
parent::__construct($transport, 1, function (Throwable $e) {
parent::__construct($transport, 1, static function (Throwable $e) {
return $e instanceof RuntimeException && $e->getMessage() === self::NO_RESPONSE;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gelf/Transport/RetryTransportWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(
private int $maxRetries,
?callable $exceptionMatcher = null
) {
$this->exceptionMatcher = Closure::fromCallable($exceptionMatcher ?? fn (Throwable $_) => true);
$this->exceptionMatcher = Closure::fromCallable($exceptionMatcher ?? static fn (Throwable $_) => true);
}

public function getTransport(): TransportInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Gelf/Transport/StreamSocketClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function write(string $buffer): int
$failed = false;
$errorMessage = "Failed to write to socket";
/** @psalm-suppress InvalidArgument */
set_error_handler(function ($errno, $errstr) use (&$failed, &$errorMessage) {
set_error_handler(static function (int $errno, string $errstr) use (&$failed, &$errorMessage) {
$failed = true;
$errorMessage .= ": $errstr ($errno)";
});
Expand Down
2 changes: 1 addition & 1 deletion src/Gelf/Transport/TcpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
) {
parent::__construct();

if ($port == self::AUTO_SSL_PORT && $this->sslOptions == null) {
if ($port === self::AUTO_SSL_PORT && $this->sslOptions === null) {
$this->sslOptions = new SslOptions();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Gelf/Transport/UdpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class UdpTransport extends AbstractTransport
/**
* Class constructor
*
* @param string $host when NULL or empty DEFAULT_HOST is used
* @param int $port when NULL or empty DEFAULT_PORT is used
* @param string $host when empty DEFAULT_HOST is used
* @param int $port when empty DEFAULT_PORT is used
* @param int $chunkSize defaults to CHUNK_SIZE_WAN,
* 0 disables chunks completely
*/
Expand All @@ -56,7 +56,7 @@ public function __construct(
) {
parent::__construct();

// allow NULL-like values for fallback on default
// fallback to default on empty values
$host = $host ?: self::DEFAULT_HOST;
$port = $port ?: self::DEFAULT_PORT;

Expand Down