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
33 changes: 0 additions & 33 deletions src/Exception/ExchangeDeclaredException.php

This file was deleted.

12 changes: 2 additions & 10 deletions src/QueueProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AbstractConnection;
use Yiisoft\Queue\AMQP\Exception\ExchangeDeclaredException;
use Yiisoft\Queue\AMQP\Settings\Exchange;
use Yiisoft\Queue\AMQP\Settings\ExchangeSettingsInterface;
use Yiisoft\Queue\AMQP\Settings\QueueSettingsInterface;
Expand Down Expand Up @@ -38,11 +37,8 @@
if ($this->channel === null) {
$this->channel = $this->connection->channel();
$this->channel->queue_declare(...$this->queueSettings->getPositionalSettings());

if ($this->exchangeSettings !== null) {
$this->channel->exchange_declare(...$this->exchangeSettings->getPositionalSettings());
$this->channel->queue_bind($this->queueSettings->getName(), $this->exchangeSettings->getName());
}
$this->channel->exchange_declare(...$this->exchangeSettings->getPositionalSettings());

Check failure on line 40 in src/QueueProvider.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.2-ubuntu-latest

PossiblyNullReference

src/QueueProvider.php:40:74: PossiblyNullReference: Cannot call method getPositionalSettings on possibly null value (see https://psalm.dev/083)

Check failure on line 40 in src/QueueProvider.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.3-ubuntu-latest

PossiblyNullReference

src/QueueProvider.php:40:74: PossiblyNullReference: Cannot call method getPositionalSettings on possibly null value (see https://psalm.dev/083)

Check failure on line 40 in src/QueueProvider.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.4-ubuntu-latest

PossiblyNullReference

src/QueueProvider.php:40:74: PossiblyNullReference: Cannot call method getPositionalSettings on possibly null value (see https://psalm.dev/083)

Check failure on line 40 in src/QueueProvider.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PossiblyNullReference

src/QueueProvider.php:40:74: PossiblyNullReference: Cannot call method getPositionalSettings on possibly null value (see https://psalm.dev/083)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->exchangeSettings can be null, so an error may occur in this line. Refactor class to exclude case when private ?AMQPChannel $channel = null; may be null.

$this->channel->queue_bind($this->queueSettings->getName(), $this->exchangeSettings->getName());
}

return $this->channel;
Expand All @@ -69,10 +65,6 @@
return $this;
}

if ($this->exchangeSettings !== null) {
throw new ExchangeDeclaredException();
}

$instance = clone $this;
$instance->channel = null;
$instance->queueSettings = $instance->queueSettings->withName($channel);
Expand Down
17 changes: 0 additions & 17 deletions tests/Unit/FriendlyExceptionTest.php

This file was deleted.

23 changes: 0 additions & 23 deletions tests/Unit/QueueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Yiisoft\Queue\AMQP\Tests\Unit;

use Yiisoft\Queue\AMQP\Adapter;
use Yiisoft\Queue\AMQP\Exception\ExchangeDeclaredException;
use Yiisoft\Queue\AMQP\QueueProvider;
use Yiisoft\Queue\AMQP\Settings\Exchange as ExchangeSettings;
use Yiisoft\Queue\AMQP\Settings\ExchangeSettingsInterface;
Expand Down Expand Up @@ -64,28 +63,6 @@ public function testWithQueueAndExchangeSettings(): void
self::assertEquals($messageBody['data']['payload']['time'], $result);
}

public function testWithChannelNameExchangeDeclaredException(): void
{
$queueProvider = new QueueProvider(
$this->createConnection(),
$this->getQueueSettings(),
);

$this->expectException(ExchangeDeclaredException::class);
new Adapter(
$queueProvider
->withQueueSettings(
new QueueSettings('yii-queue-test-with-channel-name')
)
->withExchangeSettings(
new ExchangeSettings('yii-queue-test-with-channel-name')
)
->withChannelName('yii-queue-test-channel-name'),
new JsonMessageSerializer(),
$this->getLoop(),
);
}

public function testImmutable(): void
{
$queueSettings = $this->createMock(QueueSettingsInterface::class);
Expand Down
Loading