Skip to content

Fixed php-8.4 deprecations #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
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
4 changes: 2 additions & 2 deletions pint.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"preset": "laravel",
"rules": {
"nullable_type_declaration_for_default_null_value": {
"use_nullable_type_declaration": false
"php_unit_method_casing": {
"case": "camel_case"
}
}
}
2 changes: 1 addition & 1 deletion src/Horizon/RabbitMQQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RabbitMQQueue extends BaseRabbitMQQueue
*
* @throws AMQPProtocolChannelException
*/
public function readyNow(string $queue = null): int
public function readyNow(?string $queue = null): int
{
return $this->size($queue);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/Connection/ConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ConfigFactory
*/
public static function make(array $config = []): AMQPConnectionConfig
{
return tap(new AMQPConnectionConfig(), function (AMQPConnectionConfig $connectionConfig) use ($config) {
return tap(new AMQPConnectionConfig, function (AMQPConnectionConfig $connectionConfig) use ($config) {
// Set the connection to a Lazy by default
$connectionConfig->setIsLazy(! in_array(
Arr::get($config, 'lazy') ?? true,
Expand Down
2 changes: 1 addition & 1 deletion src/Queue/QueueConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QueueConfigFactory
*/
public static function make(array $config = []): QueueConfig
{
return tap(new QueueConfig(), function (QueueConfig $queueConfig) use ($config) {
return tap(new QueueConfig, function (QueueConfig $queueConfig) use ($config) {
if (! empty($queue = Arr::get($config, 'queue'))) {
$queueConfig->setQueue($queue);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Queue/RabbitMQQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected function publishBatch($jobs, $data = '', $queue = null): void
/**
* @throws AMQPProtocolChannelException
*/
public function bulkRaw(string $payload, string $queue = null, array $options = []): int|string|null
public function bulkRaw(string $payload, ?string $queue = null, array $options = []): int|string|null
{
[$destination, $exchange, $exchangeType, $attempts] = $this->publishProperties($queue, $options);

Expand Down Expand Up @@ -397,7 +397,7 @@ public function deleteExchange(string $name, bool $unused = false): void
*
* @throws AMQPProtocolChannelException
*/
public function isQueueExists(string $name = null): bool
public function isQueueExists(?string $name = null): bool
{
$queueName = $this->getQueue($name);

Expand Down Expand Up @@ -484,7 +484,7 @@ public function bindQueue(string $queue, string $exchange, string $routingKey =
/**
* Purge the queue of messages.
*/
public function purge(string $queue = null): void
public function purge(?string $queue = null): void
{
// create a temporary channel, so the main channel will not be closed on exception
$channel = $this->createChannel();
Expand Down Expand Up @@ -637,7 +637,7 @@ protected function getDelayQueueArguments(string $destination, int $ttl): array
/**
* Get the exchange name, or empty string; as default value.
*/
protected function getExchange(string $exchange = null): string
protected function getExchange(?string $exchange = null): string
{
return $exchange ?? $this->getConfig()->getExchange();
}
Expand All @@ -654,7 +654,7 @@ protected function getRoutingKey(string $destination): string
/**
* Get the exchangeType, or AMQPExchangeType::DIRECT as default.
*/
protected function getExchangeType(string $type = null): string
protected function getExchangeType(?string $type = null): string
{
$constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getConfig()->getExchangeType());

Expand All @@ -664,7 +664,7 @@ protected function getExchangeType(string $type = null): string
/**
* Get the exchange for failed messages.
*/
protected function getFailedExchange(string $exchange = null): string
protected function getFailedExchange(?string $exchange = null): string
{
return $exchange ?? $this->getConfig()->getFailedExchange();
}
Expand Down Expand Up @@ -699,7 +699,7 @@ protected function isQueueDeclared(string $name): bool
*
* @throws AMQPProtocolChannelException
*/
protected function declareDestination(string $destination, string $exchange = null, string $exchangeType = AMQPExchangeType::DIRECT): void
protected function declareDestination(string $destination, ?string $exchange = null, string $exchangeType = AMQPExchangeType::DIRECT): void
{
// When an exchange is provided and no exchange is present in RabbitMQ, create an exchange.
if ($exchange && ! $this->isExchangeExists($exchange)) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class QueueTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand All @@ -29,7 +29,7 @@ public function testWithoutReconnect(): void
{
$queue = $this->connection('rabbitmq');

$queue->push(new TestJob());
$queue->push(new TestJob);
sleep(1);
$this->assertSame(1, $queue->size());

Expand All @@ -38,6 +38,6 @@ public function testWithoutReconnect(): void
$this->assertFalse($queue->getConnection()->isConnected());

$this->expectException(AMQPChannelClosedException::class);
$queue->push(new TestJob());
$queue->push(new TestJob);
}
}
2 changes: 1 addition & 1 deletion tests/Feature/SslQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class SslQueueTest extends TestCase
{
public function setUp(): void
protected function setUp(): void
{
$this->markTestSkipped();
}
Expand Down
20 changes: 10 additions & 10 deletions tests/Feature/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class TestCase extends BaseTestCase
/**
* @throws AMQPProtocolChannelException
*/
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -70,7 +70,7 @@ public function testPushRaw(): void

public function testPush(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

sleep(1);

Expand Down Expand Up @@ -154,7 +154,7 @@ public function testLaterRaw(): void

public function testLater(): void
{
Queue::later(3, new TestJob());
Queue::later(3, new TestJob);

sleep(1);

Expand Down Expand Up @@ -197,7 +197,7 @@ public function testBulk(): void

public function testPushEncrypted(): void
{
Queue::push(new TestEncryptedJob());
Queue::push(new TestEncryptedJob);

sleep(1);

Expand Down Expand Up @@ -251,7 +251,7 @@ public function testPushEncryptedAfterCommit(): void

public function testEncryptedLater(): void
{
Queue::later(3, new TestEncryptedJob());
Queue::later(3, new TestEncryptedJob);

sleep(1);

Expand Down Expand Up @@ -320,7 +320,7 @@ public function testReleaseRaw(): void

public function testRelease(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

sleep(1);

Expand Down Expand Up @@ -377,7 +377,7 @@ public function testReleaseWithDelayRaw(): void

public function testReleaseInThePast(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

$job = Queue::pop();
$job->release(-3);
Expand All @@ -392,7 +392,7 @@ public function testReleaseInThePast(): void

public function testReleaseAndReleaseWithDelayAttempts(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

sleep(1);

Expand All @@ -419,7 +419,7 @@ public function testReleaseAndReleaseWithDelayAttempts(): void

public function testDelete(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

$job = Queue::pop();

Expand All @@ -433,7 +433,7 @@ public function testDelete(): void

public function testFailed(): void
{
Queue::push(new TestJob());
Queue::push(new TestJob);

$job = Queue::pop();

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/RabbitMQQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testConfigExchangeType(): void
$queue = $this->connection('rabbitmq-with-options-null');
$this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType'));

//testing an unkown type with a default
// testing an unkown type with a default
$this->callProperty($queue, 'config')->setExchangeType('unknown');
$this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType'));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected function getEnvironmentSetUp($app): void
]);
}

protected function connection(string $name = null): RabbitMQQueue
protected function connection(?string $name = null): RabbitMQQueue
{
return Queue::connection($name);
}
Expand Down