diff --git a/ConsumedMessageStats.php b/ConsumedMessageStats.php index 928bce0..077ceeb 100644 --- a/ConsumedMessageStats.php +++ b/ConsumedMessageStats.php @@ -6,10 +6,10 @@ class ConsumedMessageStats implements Stats { - const STATUS_ACK = 'acknowledged'; - const STATUS_REJECTED = 'rejected'; - const STATUS_REQUEUED = 'requeued'; - const STATUS_FAILED = 'failed'; + public const STATUS_ACK = 'acknowledged'; + public const STATUS_REJECTED = 'rejected'; + public const STATUS_REQUEUED = 'requeued'; + public const STATUS_FAILED = 'failed'; /** * @var string @@ -102,12 +102,12 @@ public function __construct( array $properties, bool $redelivered, string $status, - string $errorClass = null, - string $errorMessage = null, - int $errorCode = null, - string $errorFile = null, - int $errorLine = null, - string $trace = null + ?string $errorClass = null, + ?string $errorMessage = null, + ?int $errorCode = null, + ?string $errorFile = null, + ?int $errorLine = null, + ?string $trace = null, ) { $this->consumerId = $consumerId; $this->timestampMs = $timestampMs; diff --git a/ConsumerStats.php b/ConsumerStats.php index d1a745d..d281b53 100644 --- a/ConsumerStats.php +++ b/ConsumerStats.php @@ -121,12 +121,12 @@ public function __construct( int $requeued, int $memoryUsage, float $systemLoad, - string $errorClass = null, - string $errorMessage = null, - int $errorCode = null, - string $errorFile = null, - int $errorLine = null, - string $trace = null + ?string $errorClass = null, + ?string $errorMessage = null, + ?int $errorCode = null, + ?string $errorFile = null, + ?int $errorLine = null, + ?string $trace = null, ) { $this->consumerId = $consumerId; $this->timestampMs = $timestampMs; diff --git a/DatadogStorage.php b/DatadogStorage.php index 82e841a..c10cbc6 100644 --- a/DatadogStorage.php +++ b/DatadogStorage.php @@ -30,7 +30,7 @@ public function __construct($config = 'datadog:') $this->config = $this->prepareConfig($config); if (null === $this->datadog) { - if (true === filter_var($this->config['batched'], FILTER_VALIDATE_BOOLEAN)) { + if (true === filter_var($this->config['batched'], \FILTER_VALIDATE_BOOLEAN)) { $this->datadog = new BatchedDogStatsd($this->config); } else { $this->datadog = new DogStatsd($this->config); @@ -104,10 +104,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if ('datadog' !== $dsn->getSchemeProtocol()) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "datadog"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "datadog"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [ @@ -132,11 +129,6 @@ private function parseDsn(string $dsn): array }); } - /** - * @param $config - * - * @return array - */ private function prepareConfig($config): array { if (empty($config)) { diff --git a/InfluxDbStorage.php b/InfluxDbStorage.php index ff5f6c3..3084864 100644 --- a/InfluxDbStorage.php +++ b/InfluxDbStorage.php @@ -67,9 +67,9 @@ public function __construct($config = 'influxdb:') // and causes library to use defaults. @trigger_error( sprintf('Passing %s as %s argument is deprecated. Pass it as "client" array property or use createWithClient instead', - Client::class, - __METHOD__ - ), E_USER_DEPRECATED); + Client::class, + __METHOD__ + ), \E_USER_DEPRECATED); $this->client = $config; $config = []; } else { @@ -91,12 +91,7 @@ public function __construct($config = 'influxdb:') if (null !== $config['client']) { if (!$config['client'] instanceof Client) { - throw new \InvalidArgumentException(sprintf( - '%s configuration property is expected to be an instance of %s class. %s was passed instead.', - 'client', - Client::class, - gettype($config['client']) - )); + throw new \InvalidArgumentException(sprintf('%s configuration property is expected to be an instance of %s class. %s was passed instead.', 'client', Client::class, gettype($config['client']))); } $this->client = $config['client']; } @@ -105,10 +100,7 @@ public function __construct($config = 'influxdb:') } /** - * @param Client $client * @param string $config - * - * @return InfluxDbStorage */ public static function createWithClient(Client $client, $config = 'influxdb:'): self { @@ -254,10 +246,7 @@ private static function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if (false === in_array($dsn->getSchemeProtocol(), ['influxdb'], true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "influxdb"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "influxdb"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [ diff --git a/JsonSerializer.php b/JsonSerializer.php index 1edb60e..8d04609 100644 --- a/JsonSerializer.php +++ b/JsonSerializer.php @@ -22,12 +22,8 @@ public function toString(Stats $stats): string $json = json_encode($data); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException(sprintf( - 'The malformed json given. Error %s and message %s', - json_last_error(), - json_last_error_msg() - )); + if (\JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf('The malformed json given. Error %s and message %s', json_last_error(), json_last_error_msg())); } return $json; diff --git a/Resources.php b/Resources.php index 2a5995f..409d986 100644 --- a/Resources.php +++ b/Resources.php @@ -7,7 +7,7 @@ final class Resources /** * @var array */ - private static $knownStorages = null; + private static $knownStorages; private function __construct() { diff --git a/SentMessageStats.php b/SentMessageStats.php index 6106d3d..f8ddc73 100644 --- a/SentMessageStats.php +++ b/SentMessageStats.php @@ -48,7 +48,7 @@ public function __construct( ?string $messageId, ?string $correlationId, array $headers, - array $properties + array $properties, ) { $this->timestampMs = $timestampMs; $this->destination = $destination; diff --git a/WampStorage.php b/WampStorage.php index 44623d4..0d5ba18 100644 --- a/WampStorage.php +++ b/WampStorage.php @@ -195,10 +195,7 @@ private function parseDsn(string $dsn): array $dsn = Dsn::parseFirst($dsn); if (false === in_array($dsn->getSchemeProtocol(), ['wamp', 'ws'], true)) { - throw new \LogicException(sprintf( - 'The given scheme protocol "%s" is not supported. It must be "wamp"', - $dsn->getSchemeProtocol() - )); + throw new \LogicException(sprintf('The given scheme protocol "%s" is not supported. It must be "wamp"', $dsn->getSchemeProtocol())); } return array_filter(array_replace($dsn->getQuery(), [