From 0c5fee72ab795ceaa63b85a93f25342d650dd3f6 Mon Sep 17 00:00:00 2001 From: Brian Dunne Date: Wed, 30 Oct 2024 22:17:26 -0500 Subject: [PATCH 1/2] Correct docblock types, params There were some oversights made here when types were added to these method signatures. The method signatures in question are stricter than the docblock-hinted types, so the extra docblock types have been removed to match the enforced method signatures. One docblock looks like it was copy-pasted from a different function with a completely different method signature, so the param list in the docblock has been corrected. The docblock hint for Pusher::$client hadn't been updated since curl was replaced with Guzzle as the HTTP client of choice. --- src/Pusher.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Pusher.php b/src/Pusher.php index b4e06a1..aa28039 100755 --- a/src/Pusher.php +++ b/src/Pusher.php @@ -37,9 +37,9 @@ class Pusher implements LoggerAwareInterface, PusherInterface ]; /** - * @var null|resource + * @var null|ClientInterface Guzzle client */ - private $client = null; // Guzzle client + private $client = null; /** * Initializes a new Pusher instance with key, secret, app ID and channel. @@ -136,7 +136,7 @@ public function getSettings(): array * Log a string. * * @param string $msg The message to log - * @param array|\Exception $context [optional] Any extraneous information that does not fit well in a string. + * @param array $context [optional] Any extraneous information that does not fit well in a string. * @param string $level [optional] Importance of log message, highly recommended to use Psr\Log\LogLevel::{level} */ private function log(string $msg, array $context = [], string $level = LogLevel::DEBUG): void @@ -1053,7 +1053,7 @@ public function ensure_valid_signature(array $headers, string $body): void /** * Returns an event represented by an associative array to be used in creating events and batch_events requests * - * @param array|string $channels A channel name or an array of channel names to publish the event on. + * @param array $channels An array of channel names to publish the event on. * @param string $event * @param mixed $data Event data * @param array $params [optional] @@ -1154,10 +1154,7 @@ private function make_trigger_body($channels, string $event, $data, array $param /** * Returns the body of a trigger batch events request serialized as string ready to be sent in a request * - * @param array|string $channels A channel name or an array of channel names to publish the event on. - * @param string $event - * @param mixed $data Event data - * @param array $params [optional] + * @param array $batch [optional] * @param bool $already_encoded [optional] * * @throws PusherException From 6541ecbb5ddf43c4eec3d5aaf915e7a6721c85cf Mon Sep 17 00:00:00 2001 From: Brian Dunne Date: Wed, 30 Oct 2024 22:28:47 -0500 Subject: [PATCH 2/2] Fix type errors in log calls Looks like these calls to Pusher::log() didn't get updated after #305 changed the method signature to require an array in the second param. --- src/Pusher.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pusher.php b/src/Pusher.php index aa28039..f94251b 100755 --- a/src/Pusher.php +++ b/src/Pusher.php @@ -996,7 +996,7 @@ public function webhook(array $headers, string $body): object try { $decoded_json = json_decode($body, false, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $e) { - $this->log('Unable to decrypt webhook event payload.', null, LogLevel::WARNING); + $this->log('Unable to decrypt webhook event payload.', [], LogLevel::WARNING); throw new PusherException('Data encoding error.'); } @@ -1006,12 +1006,12 @@ public function webhook(array $headers, string $body): object $decryptedEvent = $this->crypto->decrypt_event($event); if ($decryptedEvent === false) { - $this->log('Unable to decrypt webhook event payload. Wrong key? Ignoring.', null, LogLevel::WARNING); + $this->log('Unable to decrypt webhook event payload. Wrong key? Ignoring.', [], LogLevel::WARNING); continue; } $decoded_events[] = $decryptedEvent; } else { - $this->log('Got an encrypted webhook event payload, but no master key specified. Ignoring.', null, LogLevel::WARNING); + $this->log('Got an encrypted webhook event payload, but no master key specified. Ignoring.', [], LogLevel::WARNING); } } else { $decoded_events[] = $event;