diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d57cdd0..cea168a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,13 +8,13 @@ on: jobs: test: name: test - runs-on: "ubuntu-latest" + runs-on: "ubuntu-24.04" strategy: matrix: include: - - php-version: 8.2 - php-version: 8.3 + - php-version: 8.4 steps: @@ -29,13 +29,13 @@ jobs: examples: name: examples - runs-on: "ubuntu-latest" + runs-on: "ubuntu-24.04" strategy: matrix: include: - - php-version: 8.2 - php-version: 8.3 + - php-version: 8.4 steps: - name: checkout diff --git a/composer.json b/composer.json index 56827d8..66d3ddd 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,9 @@ { "name": "Christopher Davis", "email": "chris@pmg.com" } ], "require": { - "php": "^8.2", + "php": "^8.3", "psr/log": "^1.0 || ^2.0 || ^3.0", - "guzzlehttp/promises": "^1.3" + "guzzlehttp/promises": "^2.0.3" }, "require-dev": { diff --git a/src/AbstractConsumer.php b/src/AbstractConsumer.php index 9a14a29..762b55f 100644 --- a/src/AbstractConsumer.php +++ b/src/AbstractConsumer.php @@ -46,7 +46,7 @@ abstract class AbstractConsumer implements Consumer */ private $hasPcntl = null; - public function __construct(LoggerInterface $logger=null) + public function __construct(?LoggerInterface $logger=null) { $this->logger = $logger; } @@ -54,7 +54,7 @@ public function __construct(LoggerInterface $logger=null) /** * {@inheritdoc} */ - public function run(string $queueName, MessageLifecycle $lifecycle=null) : int + public function run(string $queueName, ?MessageLifecycle $lifecycle=null) : int { $lifecycle = $lifecycle ?? new Lifecycle\NullLifecycle(); $this->running = true; @@ -81,7 +81,7 @@ public function run(string $queueName, MessageLifecycle $lifecycle=null) : int /** * {@inheritdoc} */ - public function stop(int $code=null) : void + public function stop(?int $code=null) : void { $this->running = false; $this->exitCode = null === $code ? self::EXIT_SUCCESS : $code; diff --git a/src/Consumer.php b/src/Consumer.php index aded841..24d9653 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -31,7 +31,7 @@ interface Consumer * @param $lifecycle The message lifecycle to apply to the running consumer. * @return int The exit code to be used for the consumer. */ - public function run(string $queueName, MessageLifecycle $lifecycle=null) : int; + public function run(string $queueName, ?MessageLifecycle $lifecycle=null) : int; /** * Consume a single job from the given queue. This will block until the @@ -47,7 +47,7 @@ public function run(string $queueName, MessageLifecycle $lifecycle=null) : int; * @return boolean|null True if the a job was execute successfully. Null if * no job was executed. See the logs. */ - public function once(string $queueName, MessageLifecycle $lifecycle=null) : ?bool; + public function once(string $queueName, ?MessageLifecycle $lifecycle=null) : ?bool; /** * Gracefully stop the consumer with the given exit code. @@ -55,5 +55,5 @@ public function once(string $queueName, MessageLifecycle $lifecycle=null) : ?boo * @param int $code The exit code passed to `exit`. If null `EXIT_SUCCESS` is used. * @return void */ - public function stop(int $code=null) : void; + public function stop(?int $code=null) : void; } diff --git a/src/DefaultConsumer.php b/src/DefaultConsumer.php index f09727e..2a12376 100644 --- a/src/DefaultConsumer.php +++ b/src/DefaultConsumer.php @@ -54,8 +54,8 @@ class DefaultConsumer extends AbstractConsumer public function __construct( Driver $driver, MessageHandler $handler, - RetrySpec $retries=null, - LoggerInterface $logger=null + ?RetrySpec $retries=null, + ?LoggerInterface $logger=null ) { parent::__construct($logger); $this->driver = $driver; @@ -66,7 +66,7 @@ public function __construct( /** * {@inheritdoc} */ - public function once(string $queueName, MessageLifecycle $lifecycle=null) : ?bool + public function once(string $queueName, ?MessageLifecycle $lifecycle=null) : ?bool { $envelope = $this->driver->dequeue($queueName); if (!$envelope) { @@ -96,7 +96,7 @@ public function once(string $queueName, MessageLifecycle $lifecycle=null) : ?boo /** * {@inheritdoc} */ - public function stop(int $code=null) : void + public function stop(?int $code=null) : void { if ($this->currentPromise) { $this->currentPromise->cancel(); diff --git a/src/Handler/PcntlForkingHandler.php b/src/Handler/PcntlForkingHandler.php index 8581be7..ad60ddd 100644 --- a/src/Handler/PcntlForkingHandler.php +++ b/src/Handler/PcntlForkingHandler.php @@ -39,7 +39,7 @@ final class PcntlForkingHandler implements MessageHandler private Pcntl $pcntl; - public function __construct(MessageHandler $wrapped, Pcntl $pcntl=null) + public function __construct(MessageHandler $wrapped, ?Pcntl $pcntl=null) { $this->wrapped = $wrapped; $this->pcntl = $pcntl ?: new Pcntl(); diff --git a/src/Lifecycle/MappingLifecycle.php b/src/Lifecycle/MappingLifecycle.php index e8aae43..c0e8e59 100644 --- a/src/Lifecycle/MappingLifecycle.php +++ b/src/Lifecycle/MappingLifecycle.php @@ -45,7 +45,7 @@ final class MappingLifecycle implements MessageLifecycle * @param $fallback The message lifecycle to which unmatches messages will be applied * @throws InvalidArgumentException if $mapping is a bad type */ - public function __construct($mapping, MessageLifecycle $fallback=null) + public function __construct($mapping, ?MessageLifecycle $fallback=null) { if (!is_array($mapping) && !$mapping instanceof \ArrayAccess) { throw new InvalidArgumentException(sprintf( diff --git a/src/Retry/LimitedSpec.php b/src/Retry/LimitedSpec.php index c129123..31e58d8 100644 --- a/src/Retry/LimitedSpec.php +++ b/src/Retry/LimitedSpec.php @@ -29,7 +29,7 @@ final class LimitedSpec implements RetrySpec private $maxAttempts; private $retryDelay; - public function __construct(int $maxAttempts=null, int $retryDelay=0) + public function __construct(?int $maxAttempts=null, int $retryDelay=0) { if (null !== $maxAttempts && $maxAttempts < 1) { throw new InvalidArgumentException(sprintf( diff --git a/src/Serializer/NativeSerializer.php b/src/Serializer/NativeSerializer.php index 95b4ca7..1502bc6 100644 --- a/src/Serializer/NativeSerializer.php +++ b/src/Serializer/NativeSerializer.php @@ -41,13 +41,13 @@ final class NativeSerializer implements Serializer */ private $signer; - public function __construct(Signer $signer, array $allowedClasses=null) + public function __construct(Signer $signer, ?array $allowedClasses=null) { $this->signer = $signer; $this->allowedClasses = $allowedClasses; } - public static function fromSigningKey(string $key, array $allowedClasses=null) + public static function fromSigningKey(string $key, ?array $allowedClasses=null) { return new self(new HmacSha256($key), $allowedClasses); } diff --git a/test/unit/Driver/AbstractPersistanceDriverTest.php b/test/unit/Driver/AbstractPersistanceDriverTest.php index f6a07e3..9603e54 100644 --- a/test/unit/Driver/AbstractPersistanceDriverTest.php +++ b/test/unit/Driver/AbstractPersistanceDriverTest.php @@ -24,7 +24,7 @@ // not called abstract class _DriverAbc extends AbstractPersistanceDriver { - public function __construct(Serializer $serializer=null) + public function __construct(?Serializer $serializer=null) { if ($serializer) { parent::__construct($serializer); diff --git a/test/unit/Handler/PcntlForkingHandlerTest.php b/test/unit/Handler/PcntlForkingHandlerTest.php index 5a9f391..97779b4 100644 --- a/test/unit/Handler/PcntlForkingHandlerTest.php +++ b/test/unit/Handler/PcntlForkingHandlerTest.php @@ -160,7 +160,7 @@ protected function setUp() : void $this->message = new SimpleMessage(self::NAME); } - private function createHandler(callable $callback, Pcntl $pcntl=null) + private function createHandler(callable $callback, ?Pcntl $pcntl=null) { return new PcntlForkingHandler(new CallableHandler($callback), $pcntl); }