Skip to content

Commit 4435c31

Browse files
committed
[Messenger] Removed deprecated code
1 parent 7556af6 commit 4435c31

File tree

3 files changed

+17
-50
lines changed

3 files changed

+17
-50
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Remove option `prefetch_count`
8+
* Using invalid options will throw a `LogicException`
9+
410
5.3
511
---
612

Tests/Transport/ConnectionTest.php

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -125,39 +125,27 @@ public function testOptionsAreTakenIntoAccountAndOverwrittenByDsn()
125125
);
126126
}
127127

128-
/**
129-
* @group legacy
130-
*/
131-
public function testDeprecationIfInvalidOptionIsPassedWithDsn()
128+
public function testExceptionIfInvalidOptionIsPassedWithDsn()
132129
{
133-
$this->expectDeprecation('Since symfony/messenger 5.1: Invalid option(s) "foo" passed to the AMQP Messenger transport. Passing invalid options is deprecated.');
130+
$this->expectExceptionMessage('Invalid option(s) "foo" passed to the AMQP Messenger transport.');
134131
Connection::fromDsn('amqp://host?foo=bar');
135132
}
136133

137-
/**
138-
* @group legacy
139-
*/
140-
public function testDeprecationIfInvalidOptionIsPassedAsArgument()
134+
public function testExceptionIfInvalidOptionIsPassedAsArgument()
141135
{
142-
$this->expectDeprecation('Since symfony/messenger 5.1: Invalid option(s) "foo" passed to the AMQP Messenger transport. Passing invalid options is deprecated.');
136+
$this->expectExceptionMessage('Invalid option(s) "foo" passed to the AMQP Messenger transport.');
143137
Connection::fromDsn('amqp://host', ['foo' => 'bar']);
144138
}
145139

146-
/**
147-
* @group legacy
148-
*/
149-
public function testDeprecationIfInvalidQueueOptionIsPassed()
140+
public function testExceptionIfInvalidQueueOptionIsPassed()
150141
{
151-
$this->expectDeprecation('Since symfony/messenger 5.1: Invalid queue option(s) "foo" passed to the AMQP Messenger transport. Passing invalid queue options is deprecated.');
142+
$this->expectExceptionMessage('Invalid queue option(s) "foo" passed to the AMQP Messenger transport.');
152143
Connection::fromDsn('amqp://host', ['queues' => ['queueName' => ['foo' => 'bar']]]);
153144
}
154145

155-
/**
156-
* @group legacy
157-
*/
158-
public function testDeprecationIfInvalidExchangeOptionIsPassed()
146+
public function testExceptionIfInvalidExchangeOptionIsPassed()
159147
{
160-
$this->expectDeprecation('Since symfony/messenger 5.1: Invalid exchange option(s) "foo" passed to the AMQP Messenger transport. Passing invalid exchange options is deprecated.');
148+
$this->expectExceptionMessage('Invalid exchange option(s) "foo" passed to the AMQP Messenger transport.');
161149
Connection::fromDsn('amqp://host', ['exchange' => ['foo' => 'bar']]);
162150
}
163151

@@ -439,28 +427,6 @@ public function testItSetupQueuesOnce()
439427
$connection->publish('body');
440428
}
441429

442-
/**
443-
* @group legacy
444-
*/
445-
public function testSetChannelPrefetchWhenSetup()
446-
{
447-
$factory = new TestAmqpFactory(
448-
$amqpConnection = $this->createMock(\AMQPConnection::class),
449-
$amqpChannel = $this->createMock(\AMQPChannel::class),
450-
$amqpQueue = $this->createMock(\AMQPQueue::class),
451-
$amqpExchange = $this->createMock(\AMQPExchange::class)
452-
);
453-
454-
// makes sure the channel looks connected, so it's not re-created
455-
$amqpChannel->expects($this->any())->method('isConnected')->willReturn(true);
456-
457-
$amqpChannel->expects($this->never())->method('setPrefetchCount');
458-
459-
$this->expectDeprecation('Since symfony/messenger 5.3: The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.');
460-
$connection = Connection::fromDsn('amqp://localhost?prefetch_count=2', [], $factory);
461-
$connection->setup();
462-
}
463-
464430
public function testAutoSetupWithDelayDeclaresExchangeQueuesAndDelay()
465431
{
466432
$amqpConnection = $this->createMock(\AMQPConnection::class);

Transport/Connection.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class Connection
4343
'exchange',
4444
'delay',
4545
'auto_setup',
46-
'prefetch_count',
4746
'retry',
4847
'persistent',
4948
'frame_max',
@@ -238,11 +237,7 @@ public static function fromDsn(string $dsn, array $options = [], AmqpFactory $am
238237
private static function validateOptions(array $options): void
239238
{
240239
if (0 < \count($invalidOptions = array_diff(array_keys($options), self::AVAILABLE_OPTIONS))) {
241-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid option(s) "%s" passed to the AMQP Messenger transport. Passing invalid options is deprecated.', implode('", "', $invalidOptions));
242-
}
243-
244-
if (isset($options['prefetch_count'])) {
245-
trigger_deprecation('symfony/messenger', '5.3', 'The "prefetch_count" option passed to the AMQP Messenger transport has no effect and should not be used.');
240+
throw new LogicException(sprintf('Invalid option(s) "%s" passed to the AMQP Messenger transport.', implode('", "', $invalidOptions)));
246241
}
247242

248243
if (\is_array($options['queues'] ?? false)) {
@@ -252,14 +247,14 @@ private static function validateOptions(array $options): void
252247
}
253248

254249
if (0 < \count($invalidQueueOptions = array_diff(array_keys($queue), self::AVAILABLE_QUEUE_OPTIONS))) {
255-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid queue option(s) "%s" passed to the AMQP Messenger transport. Passing invalid queue options is deprecated.', implode('", "', $invalidQueueOptions));
250+
throw new LogicException(sprintf('Invalid queue option(s) "%s" passed to the AMQP Messenger transport.', implode('", "', $invalidQueueOptions)));
256251
}
257252
}
258253
}
259254

260255
if (\is_array($options['exchange'] ?? false)
261256
&& 0 < \count($invalidExchangeOptions = array_diff(array_keys($options['exchange']), self::AVAILABLE_EXCHANGE_OPTIONS))) {
262-
trigger_deprecation('symfony/messenger', '5.1', 'Invalid exchange option(s) "%s" passed to the AMQP Messenger transport. Passing invalid exchange options is deprecated.', implode('", "', $invalidExchangeOptions));
257+
throw new LogicException(sprintf('Invalid exchange option(s) "%s" passed to the AMQP Messenger transport.', implode('", "', $invalidExchangeOptions)));
263258
}
264259
}
265260

0 commit comments

Comments
 (0)