Skip to content

Commit b6343c8

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
1 parent f8bc975 commit b6343c8

File tree

7 files changed

+33
-33
lines changed

7 files changed

+33
-33
lines changed

Tests/Transport/AmqpReceiverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testItThrowsATransportExceptionIfItCannotRejectMessage()
6767
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
6868
$connection->method('getQueueNames')->willReturn(['queueName']);
6969
$connection->method('get')->with('queueName')->willReturn($amqpEnvelope);
70-
$connection->method('nack')->with($amqpEnvelope, 'queueName', AMQP_NOPARAM)->willThrowException(new \AMQPException());
70+
$connection->method('nack')->with($amqpEnvelope, 'queueName', \AMQP_NOPARAM)->willThrowException(new \AMQPException());
7171

7272
$receiver = new AmqpReceiver($connection, $serializer);
7373
$receiver->reject(new Envelope(new \stdClass(), [new AmqpReceivedStamp($amqpEnvelope, 'queueName')]));

Tests/Transport/AmqpSenderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testContentTypeHeaderIsMovedToAttribute()
7979

8080
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock();
8181
unset($encoded['headers']['Content-Type']);
82-
$stamp = new AmqpStamp(null, AMQP_NOPARAM, ['content_type' => 'application/json']);
82+
$stamp = new AmqpStamp(null, \AMQP_NOPARAM, ['content_type' => 'application/json']);
8383
$connection->expects($this->once())->method('publish')->with($encoded['body'], $encoded['headers'], 0, $stamp);
8484

8585
$sender = new AmqpSender($connection, $serializer);
@@ -88,7 +88,7 @@ public function testContentTypeHeaderIsMovedToAttribute()
8888

8989
public function testContentTypeHeaderDoesNotOverwriteAttribute()
9090
{
91-
$envelope = (new Envelope(new DummyMessage('Oy')))->with($stamp = new AmqpStamp('rk', AMQP_NOPARAM, ['content_type' => 'custom']));
91+
$envelope = (new Envelope(new DummyMessage('Oy')))->with($stamp = new AmqpStamp('rk', \AMQP_NOPARAM, ['content_type' => 'custom']));
9292
$encoded = ['body' => '...', 'headers' => ['type' => DummyMessage::class, 'Content-Type' => 'application/json']];
9393

9494
$serializer = $this->getMockBuilder(SerializerInterface::class)->getMock();

Tests/Transport/AmqpStampTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public function testRoutingKeyOnly()
2323
{
2424
$stamp = new AmqpStamp('routing_key');
2525
$this->assertSame('routing_key', $stamp->getRoutingKey());
26-
$this->assertSame(AMQP_NOPARAM, $stamp->getFlags());
26+
$this->assertSame(\AMQP_NOPARAM, $stamp->getFlags());
2727
$this->assertSame([], $stamp->getAttributes());
2828
}
2929

3030
public function testFlagsAndAttributes()
3131
{
32-
$stamp = new AmqpStamp(null, AMQP_DURABLE, ['delivery_mode' => 'unknown']);
32+
$stamp = new AmqpStamp(null, \AMQP_DURABLE, ['delivery_mode' => 'unknown']);
3333
$this->assertNull($stamp->getRoutingKey());
34-
$this->assertSame(AMQP_DURABLE, $stamp->getFlags());
34+
$this->assertSame(\AMQP_DURABLE, $stamp->getFlags());
3535
$this->assertSame(['delivery_mode' => 'unknown'], $stamp->getAttributes());
3636
}
3737

@@ -49,7 +49,7 @@ public function testCreateFromAmqpEnvelope()
4949
$this->assertSame($amqpEnvelope->getDeliveryMode(), $stamp->getAttributes()['delivery_mode']);
5050
$this->assertSame($amqpEnvelope->getPriority(), $stamp->getAttributes()['priority']);
5151
$this->assertSame($amqpEnvelope->getAppId(), $stamp->getAttributes()['app_id']);
52-
$this->assertSame(AMQP_NOPARAM, $stamp->getFlags());
52+
$this->assertSame(\AMQP_NOPARAM, $stamp->getFlags());
5353
}
5454

5555
public function testCreateFromAmqpEnvelopeWithPreviousStamp()
@@ -60,14 +60,14 @@ public function testCreateFromAmqpEnvelopeWithPreviousStamp()
6060
$amqpEnvelope->method('getPriority')->willReturn(5);
6161
$amqpEnvelope->method('getAppId')->willReturn('appid');
6262

63-
$previousStamp = new AmqpStamp('otherroutingkey', AMQP_MANDATORY, ['priority' => 8]);
63+
$previousStamp = new AmqpStamp('otherroutingkey', \AMQP_MANDATORY, ['priority' => 8]);
6464

6565
$stamp = AmqpStamp::createFromAmqpEnvelope($amqpEnvelope, $previousStamp);
6666

6767
$this->assertSame('otherroutingkey', $stamp->getRoutingKey());
6868
$this->assertSame($amqpEnvelope->getDeliveryMode(), $stamp->getAttributes()['delivery_mode']);
6969
$this->assertSame(8, $stamp->getAttributes()['priority']);
7070
$this->assertSame($amqpEnvelope->getAppId(), $stamp->getAttributes()['app_id']);
71-
$this->assertSame(AMQP_MANDATORY, $stamp->getFlags());
71+
$this->assertSame(\AMQP_MANDATORY, $stamp->getFlags());
7272
}
7373
}

Tests/Transport/ConnectionTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function testItSetupsTheConnectionWithDefaults()
266266
);
267267

268268
$amqpExchange->expects($this->once())->method('declareExchange');
269-
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
269+
$amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
270270
$amqpQueue->expects($this->once())->method('declareQueue');
271271
$amqpQueue->expects($this->once())->method('bind')->with(self::DEFAULT_EXCHANGE_NAME, null);
272272

@@ -289,7 +289,7 @@ public function testItSetupsTheConnection()
289289
$factory->method('createQueue')->will($this->onConsecutiveCalls($amqpQueue0, $amqpQueue1));
290290

291291
$amqpExchange->expects($this->once())->method('declareExchange');
292-
$amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
292+
$amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
293293
$amqpQueue0->expects($this->once())->method('declareQueue');
294294
$amqpQueue0->expects($this->exactly(2))->method('bind')->withConsecutive(
295295
[self::DEFAULT_EXCHANGE_NAME, 'binding_key0'],
@@ -326,7 +326,7 @@ public function testBindingArguments()
326326
$factory->method('createQueue')->willReturn($amqpQueue);
327327

328328
$amqpExchange->expects($this->once())->method('declareExchange');
329-
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
329+
$amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
330330
$amqpQueue->expects($this->once())->method('declareQueue');
331331
$amqpQueue->expects($this->exactly(1))->method('bind')->withConsecutive(
332332
[self::DEFAULT_EXCHANGE_NAME, null, ['x-match' => 'all']]
@@ -439,7 +439,7 @@ public function testItDelaysTheMessage()
439439
$delayQueue->expects($this->once())->method('declareQueue');
440440
$delayQueue->expects($this->once())->method('bind')->with('delays', 'delay_messages__5000');
441441

442-
$delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__5000', AMQP_NOPARAM, ['headers' => ['x-some-headers' => 'foo'], 'delivery_mode' => 2]);
442+
$delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__5000', \AMQP_NOPARAM, ['headers' => ['x-some-headers' => 'foo'], 'delivery_mode' => 2]);
443443

444444
$connection = Connection::fromDsn('amqp://localhost', [], $factory);
445445
$connection->publish('{}', ['x-some-headers' => 'foo'], 5000);
@@ -481,7 +481,7 @@ public function testItDelaysTheMessageWithADifferentRoutingKeyAndTTLs()
481481
$delayQueue->expects($this->once())->method('declareQueue');
482482
$delayQueue->expects($this->once())->method('bind')->with('delays', 'delay_messages__120000');
483483

484-
$delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__120000', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
484+
$delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages__120000', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
485485
$connection->publish('{}', [], 120000);
486486
}
487487

@@ -513,10 +513,10 @@ public function testAmqpStampHeadersAreUsed()
513513
$amqpExchange = $this->createMock(\AMQPExchange::class)
514514
);
515515

516-
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => ['Foo' => 'X', 'Bar' => 'Y'], 'delivery_mode' => 2]);
516+
$amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => ['Foo' => 'X', 'Bar' => 'Y'], 'delivery_mode' => 2]);
517517

518518
$connection = Connection::fromDsn('amqp://localhost', [], $factory);
519-
$connection->publish('body', ['Foo' => 'X'], 0, new AmqpStamp(null, AMQP_NOPARAM, ['headers' => ['Bar' => 'Y']]));
519+
$connection->publish('body', ['Foo' => 'X'], 0, new AmqpStamp(null, \AMQP_NOPARAM, ['headers' => ['Bar' => 'Y']]));
520520
}
521521

522522
public function testAmqpStampDelireryModeIsUsed()
@@ -528,10 +528,10 @@ public function testAmqpStampDelireryModeIsUsed()
528528
$amqpExchange = $this->createMock(\AMQPExchange::class)
529529
);
530530

531-
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 1]);
531+
$amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 1]);
532532

533533
$connection = Connection::fromDsn('amqp://localhost', [], $factory);
534-
$connection->publish('body', [], 0, new AmqpStamp(null, AMQP_NOPARAM, ['delivery_mode' => 1]));
534+
$connection->publish('body', [], 0, new AmqpStamp(null, \AMQP_NOPARAM, ['delivery_mode' => 1]));
535535
}
536536

537537
public function testItCanPublishWithTheDefaultRoutingKey()
@@ -600,7 +600,7 @@ public function testItDelaysTheMessageWithTheInitialSuppliedRoutingKeyAsArgument
600600
$delayQueue->expects($this->once())->method('declareQueue');
601601
$delayQueue->expects($this->once())->method('bind')->with('delays', 'delay_messages_routing_key_120000');
602602

603-
$delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages_routing_key_120000', AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
603+
$delayExchange->expects($this->once())->method('publish')->with('{}', 'delay_messages_routing_key_120000', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
604604
$connection->publish('{}', [], 120000, new AmqpStamp('routing_key'));
605605
}
606606

@@ -616,12 +616,12 @@ public function testItCanPublishWithCustomFlagsAndAttributes()
616616
$amqpExchange->expects($this->once())->method('publish')->with(
617617
'body',
618618
'routing_key',
619-
AMQP_IMMEDIATE,
619+
\AMQP_IMMEDIATE,
620620
['delivery_mode' => 2, 'headers' => ['type' => DummyMessage::class]]
621621
);
622622

623623
$connection = Connection::fromDsn('amqp://localhost', [], $factory);
624-
$connection->publish('body', ['type' => DummyMessage::class], 0, new AmqpStamp('routing_key', AMQP_IMMEDIATE, ['delivery_mode' => 2]));
624+
$connection->publish('body', ['type' => DummyMessage::class], 0, new AmqpStamp('routing_key', \AMQP_IMMEDIATE, ['delivery_mode' => 2]));
625625
}
626626
}
627627

Transport/AmqpReceiver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function getMessageCount(): int
120120
private function rejectAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, string $queueName): void
121121
{
122122
try {
123-
$this->connection->nack($amqpEnvelope, $queueName, AMQP_NOPARAM);
123+
$this->connection->nack($amqpEnvelope, $queueName, \AMQP_NOPARAM);
124124
} catch (\AMQPException $exception) {
125125
throw new TransportException($exception->getMessage(), 0, $exception);
126126
}

Transport/AmqpStamp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class AmqpStamp implements NonSendableStampInterface
2323
private $flags;
2424
private $attributes;
2525

26-
public function __construct(string $routingKey = null, int $flags = AMQP_NOPARAM, array $attributes = [])
26+
public function __construct(string $routingKey = null, int $flags = \AMQP_NOPARAM, array $attributes = [])
2727
{
2828
$this->routingKey = $routingKey;
2929
$this->flags = $flags;
@@ -62,14 +62,14 @@ public static function createFromAmqpEnvelope(\AMQPEnvelope $amqpEnvelope, self
6262
$attr['type'] = $attr['type'] ?? $amqpEnvelope->getType();
6363
$attr['reply_to'] = $attr['reply_to'] ?? $amqpEnvelope->getReplyTo();
6464

65-
return new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey(), $previousStamp->flags ?? AMQP_NOPARAM, $attr);
65+
return new self($previousStamp->routingKey ?? $amqpEnvelope->getRoutingKey(), $previousStamp->flags ?? \AMQP_NOPARAM, $attr);
6666
}
6767

6868
public static function createWithAttributes(array $attributes, self $previousStamp = null): self
6969
{
7070
return new self(
7171
$previousStamp->routingKey ?? null,
72-
$previousStamp->flags ?? AMQP_NOPARAM,
72+
$previousStamp->flags ?? \AMQP_NOPARAM,
7373
array_merge($previousStamp->attributes ?? [], $attributes)
7474
);
7575
}

Transport/Connection.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ private function publishOnExchange(\AMQPExchange $exchange, string $body, string
321321
$exchange->publish(
322322
$body,
323323
$routingKey,
324-
$amqpStamp ? $amqpStamp->getFlags() : AMQP_NOPARAM,
324+
$amqpStamp ? $amqpStamp->getFlags() : \AMQP_NOPARAM,
325325
$attributes
326326
);
327327
}
@@ -342,8 +342,8 @@ private function getDelayExchange(): \AMQPExchange
342342
if (null === $this->amqpDelayExchange) {
343343
$this->amqpDelayExchange = $this->amqpFactory->createExchange($this->channel());
344344
$this->amqpDelayExchange->setName($this->connectionOptions['delay']['exchange_name']);
345-
$this->amqpDelayExchange->setType(AMQP_EX_TYPE_DIRECT);
346-
$this->amqpDelayExchange->setFlags(AMQP_DURABLE);
345+
$this->amqpDelayExchange->setType(\AMQP_EX_TYPE_DIRECT);
346+
$this->amqpDelayExchange->setFlags(\AMQP_DURABLE);
347347
}
348348

349349
return $this->amqpDelayExchange;
@@ -366,7 +366,7 @@ private function createDelayQueue(int $delay, ?string $routingKey): \AMQPQueue
366366
[$delay, $this->exchangeOptions['name'], $routingKey ?? ''],
367367
$this->connectionOptions['delay']['queue_name_pattern']
368368
));
369-
$queue->setFlags(AMQP_DURABLE);
369+
$queue->setFlags(\AMQP_DURABLE);
370370
$queue->setArguments([
371371
'x-message-ttl' => $delay,
372372
// delete the delay queue 10 seconds after the message expires
@@ -426,7 +426,7 @@ public function ack(\AMQPEnvelope $message, string $queueName): bool
426426
return $this->queue($queueName)->ack($message->getDeliveryTag());
427427
}
428428

429-
public function nack(\AMQPEnvelope $message, string $queueName, int $flags = AMQP_NOPARAM): bool
429+
public function nack(\AMQPEnvelope $message, string $queueName, int $flags = \AMQP_NOPARAM): bool
430430
{
431431
return $this->queue($queueName)->nack($message->getDeliveryTag(), $flags);
432432
}
@@ -489,7 +489,7 @@ public function queue(string $queueName): \AMQPQueue
489489

490490
$amqpQueue = $this->amqpFactory->createQueue($this->channel());
491491
$amqpQueue->setName($queueName);
492-
$amqpQueue->setFlags($queueConfig['flags'] ?? AMQP_DURABLE);
492+
$amqpQueue->setFlags($queueConfig['flags'] ?? \AMQP_DURABLE);
493493

494494
if (isset($queueConfig['arguments'])) {
495495
$amqpQueue->setArguments($queueConfig['arguments']);
@@ -506,8 +506,8 @@ public function exchange(): \AMQPExchange
506506
if (null === $this->amqpExchange) {
507507
$this->amqpExchange = $this->amqpFactory->createExchange($this->channel());
508508
$this->amqpExchange->setName($this->exchangeOptions['name']);
509-
$this->amqpExchange->setType($this->exchangeOptions['type'] ?? AMQP_EX_TYPE_FANOUT);
510-
$this->amqpExchange->setFlags($this->exchangeOptions['flags'] ?? AMQP_DURABLE);
509+
$this->amqpExchange->setType($this->exchangeOptions['type'] ?? \AMQP_EX_TYPE_FANOUT);
510+
$this->amqpExchange->setFlags($this->exchangeOptions['flags'] ?? \AMQP_DURABLE);
511511

512512
if (isset($this->exchangeOptions['arguments'])) {
513513
$this->amqpExchange->setArguments($this->exchangeOptions['arguments']);

0 commit comments

Comments
 (0)