From 123d60da14ad1e8e3c59c397c16dac4f95dc3c6f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 24 Jan 2026 15:47:29 +0300 Subject: [PATCH 1/2] Move `DEFAULT_CHANNEL` constant to `QueueProviderInterface` --- config/params.php | 2 +- src/Adapter/SynchronousAdapter.php | 3 ++- src/Command/ListenCommand.php | 2 +- src/Provider/QueueProviderInterface.php | 3 +++ src/QueueInterface.php | 3 --- stubs/StubAdapter.php | 3 ++- tests/Unit/Adapter/SynchronousAdapterTest.php | 3 ++- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/params.php b/config/params.php index 086f8f70..0f88110e 100644 --- a/config/params.php +++ b/config/params.php @@ -24,7 +24,7 @@ 'yiisoft/queue' => [ 'handlers' => [], 'channels' => [ - QueueInterface::DEFAULT_CHANNEL => AdapterInterface::class, + QueueProviderInterface::DEFAULT_CHANNEL => AdapterInterface::class, ], 'middlewares-push' => [], 'middlewares-consume' => [], diff --git a/src/Adapter/SynchronousAdapter.php b/src/Adapter/SynchronousAdapter.php index 26789295..c92e95a8 100644 --- a/src/Adapter/SynchronousAdapter.php +++ b/src/Adapter/SynchronousAdapter.php @@ -9,6 +9,7 @@ use Yiisoft\Queue\ChannelNormalizer; use Yiisoft\Queue\JobStatus; use Yiisoft\Queue\Message\MessageInterface; +use Yiisoft\Queue\Provider\QueueProviderInterface; use Yiisoft\Queue\QueueInterface; use Yiisoft\Queue\Worker\WorkerInterface; use Yiisoft\Queue\Message\IdEnvelope; @@ -22,7 +23,7 @@ final class SynchronousAdapter implements AdapterInterface public function __construct( private readonly WorkerInterface $worker, private readonly QueueInterface $queue, - string|BackedEnum $channel = QueueInterface::DEFAULT_CHANNEL, + string|BackedEnum $channel = QueueProviderInterface::DEFAULT_CHANNEL, ) { $this->channel = ChannelNormalizer::normalize($channel); } diff --git a/src/Command/ListenCommand.php b/src/Command/ListenCommand.php index 3207385f..f1b1bbbd 100644 --- a/src/Command/ListenCommand.php +++ b/src/Command/ListenCommand.php @@ -30,7 +30,7 @@ public function configure(): void 'channel', InputArgument::OPTIONAL, 'Queue channel name to connect to', - QueueInterface::DEFAULT_CHANNEL, + QueueProviderInterface::DEFAULT_CHANNEL, ); } diff --git a/src/Provider/QueueProviderInterface.php b/src/Provider/QueueProviderInterface.php index d833a84b..2655b17a 100644 --- a/src/Provider/QueueProviderInterface.php +++ b/src/Provider/QueueProviderInterface.php @@ -12,6 +12,9 @@ */ interface QueueProviderInterface { + /** @psalm-suppress MissingClassConstType */ + public const DEFAULT_CHANNEL = 'yii-queue'; + /** * Find a queue by channel name and returns it. * diff --git a/src/QueueInterface.php b/src/QueueInterface.php index f31d36c0..1985c32e 100644 --- a/src/QueueInterface.php +++ b/src/QueueInterface.php @@ -11,9 +11,6 @@ interface QueueInterface { - /** @psalm-suppress MissingClassConstType */ - public const DEFAULT_CHANNEL = 'yii-queue'; - /** * Pushes a message into the queue. * diff --git a/stubs/StubAdapter.php b/stubs/StubAdapter.php index 98cf273f..2ea78aab 100644 --- a/stubs/StubAdapter.php +++ b/stubs/StubAdapter.php @@ -9,6 +9,7 @@ use Yiisoft\Queue\ChannelNormalizer; use Yiisoft\Queue\JobStatus; use Yiisoft\Queue\Message\MessageInterface; +use Yiisoft\Queue\Provider\QueueProviderInterface; use Yiisoft\Queue\QueueInterface; /** @@ -19,7 +20,7 @@ final class StubAdapter implements AdapterInterface private string $channel; public function __construct( - string|BackedEnum $channel = QueueInterface::DEFAULT_CHANNEL + string|BackedEnum $channel = QueueProviderInterface::DEFAULT_CHANNEL ) { $this->channel = ChannelNormalizer::normalize($channel); } diff --git a/tests/Unit/Adapter/SynchronousAdapterTest.php b/tests/Unit/Adapter/SynchronousAdapterTest.php index 7d2758ce..88479dc6 100644 --- a/tests/Unit/Adapter/SynchronousAdapterTest.php +++ b/tests/Unit/Adapter/SynchronousAdapterTest.php @@ -10,6 +10,7 @@ use Yiisoft\Queue\JobStatus; use Yiisoft\Queue\Message\IdEnvelope; use Yiisoft\Queue\Message\Message; +use Yiisoft\Queue\Provider\QueueProviderInterface; use Yiisoft\Queue\QueueInterface; use Yiisoft\Queue\Stubs\StubQueue; use Yiisoft\Queue\Stubs\StubWorker; @@ -58,7 +59,7 @@ public function testIdSetting(): void public function testWithSameChannel(): void { $adapter = $this->getAdapter(); - self::assertEquals($adapter, $adapter->withChannel(QueueInterface::DEFAULT_CHANNEL)); + self::assertEquals($adapter, $adapter->withChannel(QueueProviderInterface::DEFAULT_CHANNEL)); } public function testWithAnotherChannel(): void From 1c857bb8be7a1f2924d56ee2967fe10a577b0ea6 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sat, 24 Jan 2026 12:47:47 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- config/params.php | 1 - src/Command/ListenCommand.php | 1 - stubs/StubAdapter.php | 1 - tests/Unit/Adapter/SynchronousAdapterTest.php | 1 - 4 files changed, 4 deletions(-) diff --git a/config/params.php b/config/params.php index 0f88110e..2195a8cb 100644 --- a/config/params.php +++ b/config/params.php @@ -10,7 +10,6 @@ use Yiisoft\Queue\Debug\QueueProviderInterfaceProxy; use Yiisoft\Queue\Debug\QueueWorkerInterfaceProxy; use Yiisoft\Queue\Provider\QueueProviderInterface; -use Yiisoft\Queue\QueueInterface; use Yiisoft\Queue\Worker\WorkerInterface; return [ diff --git a/src/Command/ListenCommand.php b/src/Command/ListenCommand.php index f1b1bbbd..a025b8fd 100644 --- a/src/Command/ListenCommand.php +++ b/src/Command/ListenCommand.php @@ -10,7 +10,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Yiisoft\Queue\Provider\QueueProviderInterface; -use Yiisoft\Queue\QueueInterface; #[AsCommand( 'queue:listen', diff --git a/stubs/StubAdapter.php b/stubs/StubAdapter.php index 2ea78aab..e7332e2d 100644 --- a/stubs/StubAdapter.php +++ b/stubs/StubAdapter.php @@ -10,7 +10,6 @@ use Yiisoft\Queue\JobStatus; use Yiisoft\Queue\Message\MessageInterface; use Yiisoft\Queue\Provider\QueueProviderInterface; -use Yiisoft\Queue\QueueInterface; /** * Stub adapter that does nothing. Job status is always "done". diff --git a/tests/Unit/Adapter/SynchronousAdapterTest.php b/tests/Unit/Adapter/SynchronousAdapterTest.php index 88479dc6..acdce04d 100644 --- a/tests/Unit/Adapter/SynchronousAdapterTest.php +++ b/tests/Unit/Adapter/SynchronousAdapterTest.php @@ -11,7 +11,6 @@ use Yiisoft\Queue\Message\IdEnvelope; use Yiisoft\Queue\Message\Message; use Yiisoft\Queue\Provider\QueueProviderInterface; -use Yiisoft\Queue\QueueInterface; use Yiisoft\Queue\Stubs\StubQueue; use Yiisoft\Queue\Stubs\StubWorker; use Yiisoft\Queue\Tests\TestCase;