Skip to content

Commit

Permalink
Support Symfony 7
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-daubois committed Mar 14, 2024
1 parent bb6e759 commit cf09d11
Show file tree
Hide file tree
Showing 16 changed files with 123 additions and 125 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,19 @@ jobs:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
symfony_version: ['5.4.*', '6.2.*', '6.3.*']
symfony_version: ['5.4.*', '6.4.*', '7.0.*']
dependencies: ['--prefer-lowest', '--prefer-dist']
exclude:
- php: '7.4'
symfony_version: '6.2.*'
symfony_version: '6.4.*'
- php: '7.4'
symfony_version: '6.3.*'
symfony_version: '7.0.*'
- php: '8.0'
symfony_version: '6.2.*'
symfony_version: '6.4.*'
- php: '8.0'
symfony_version: '6.3.*'
symfony_version: '7.0.*'
- php: '8.1'
symfony_version: '7.0.*'

name: PHP ${{ matrix.php }} unit tests on Sf ${{ matrix.symfony_version }}, deps=${{ matrix.dependencies }}

Expand Down Expand Up @@ -127,18 +129,20 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2'] # same as in the container
symfony_version: ['5.4.*', '6.2.*', '6.3.*']
dependencies: ['--prefer-lowest', '--prefer-dist']
php: [ '7.4', '8.0', '8.1', '8.2' ] # same as in the container
symfony_version: [ '5.4.*', '6.4.*', '7.0.*' ]
dependencies: [ '--prefer-lowest', '--prefer-dist' ]
exclude:
- php: '7.4'
symfony_version: '6.2.*'
symfony_version: '6.4.*'
- php: '7.4'
symfony_version: '6.3.*'
symfony_version: '7.0.*'
- php: '8.0'
symfony_version: '6.2.*'
symfony_version: '6.4.*'
- php: '8.0'
symfony_version: '6.3.*'
symfony_version: '7.0.*'
- php: '8.1'
symfony_version: '7.0.*'

name: PHP ${{ matrix.php }} functional tests on Sf ${{ matrix.symfony_version }}, deps=${{ matrix.dependencies }}

Expand Down Expand Up @@ -180,4 +184,4 @@ jobs:
if: ${{ matrix.php != '8.1' && matrix.php != '8.2' }}

- run: bin/test.sh --exclude-group=gearman
if: ${{ matrix.php == '8.1' && matrix.php != '8.2' }}
if: ${{ matrix.php == '8.1' || matrix.php == '8.2' }}
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@
"phpunit/phpunit": "^9.5",
"phpstan/phpstan": "^0.12",
"queue-interop/queue-spec": "^0.6.2",
"symfony/browser-kit": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/console": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/event-dispatcher": "^5.4|^6.0",
"symfony/expression-language": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/filesystem": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/validator": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0",
"symfony/browser-kit": "^5.4|^6.4|^7.0",
"symfony/config": "^5.4|^6.4|^7.0",
"symfony/process": "^5.4|^6.4|^7.0",
"symfony/console": "^5.4|^6.4|^7.0",
"symfony/dependency-injection": "^5.4|^6.4|^7.0",
"symfony/event-dispatcher": "^5.4|^6.4|^7.0",
"symfony/expression-language": "^5.4|^6.4|^7.0",
"symfony/http-kernel": "^5.4|^6.4|^7.0",
"symfony/filesystem": "^5.4|^6.4|^7.0",
"symfony/framework-bundle": "^5.4|^6.4|^7.0",
"symfony/validator": "^5.4|^6.4|^7.0",
"symfony/yaml": "^5.4|^6.4|^7.0",
"empi89/php-amqp-stubs": "*@dev",
"doctrine/doctrine-bundle": "^2.3.2",
"doctrine/mongodb-odm-bundle": "^3.5|^4.3",
"doctrine/mongodb-odm-bundle": "^3.5|^4.3|^5.0",
"alcaeus/mongo-php-adapter": "^1.0",
"kwn/php-rdkafka-stubs": "^2.0.3",
"friendsofphp/php-cs-fixer": "^3.4",
Expand Down Expand Up @@ -125,7 +125,7 @@
"ext-amqp": "1.9.3",
"ext-gearman": "2.0.3",
"ext-rdkafka": "4.0",
"ext-mongodb": "1.5",
"ext-mongodb": "1.11",
"ext-bcmath": "1",
"ext-mbstring": "1",
"ext-mongo": "1.6.14",
Expand Down
15 changes: 7 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ services:
- PREDIS_DSN=redis+predis://redis
- PHPREDIS_DSN=redis+phpredis://redis
- GPS_DSN=gps:?projectId=mqdev&emulatorHost=http://google-pubsub:8085
- SQS_DSN=sqs:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4576&version=latest
- SNS_DSN=sns:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4575&version=latest
- SNSQS_DSN=snsqs:?key=key&secret=secret&region=us-east-1&sns_endpoint=http://localstack:4575&sqs_endpoint=http://localstack:4576&version=latest
- SQS_DSN=sqs:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4566&version=latest
- SNS_DSN=sns:?key=key&secret=secret&region=us-east-1&endpoint=http://localstack:4566&version=latest
- SNSQS_DSN=snsqs:?key=key&secret=secret&region=us-east-1&sns_endpoint=http://localstack:4566&sqs_endpoint=http://localstack:4566&version=latest
- WAMP_DSN=wamp://thruway:9090
- REDIS_HOST=redis
- REDIS_PORT=6379
- AWS_SQS_KEY=key
- AWS_SQS_SECRET=secret
- AWS_SQS_REGION=us-east-1
- AWS_SQS_ENDPOINT=http://localstack:4576
- AWS_SQS_ENDPOINT=http://localstack:4566
- AWS_SQS_VERSION=latest
- BEANSTALKD_DSN=beanstalk://beanstalkd:11300
- GEARMAN_DSN=gearman://gearmand:4730
Expand Down Expand Up @@ -127,13 +127,12 @@ services:
- '9090:9090'

localstack:
image: 'localstack/localstack:0.8.10'
image: 'localstack/localstack:3.0.2'
ports:
- '4576:4576'
- '4575:4575'
- '4566:4566'
environment:
HOSTNAME_EXTERNAL: 'localstack'
SERVICES: 'sqs,sns'
LOCALSTACK_HOST: 'localstack:4566'

influxdb:
image: 'influxdb:latest'
Expand Down
2 changes: 1 addition & 1 deletion docker/bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ waitForService gearmand 4730 50
waitForService kafka 9092 50
waitForService mongo 27017 50
waitForService thruway 9090 50
waitForService localstack 4576 50
waitForService localstack 4566 50

php docker/bin/refresh-mysql-database.php || exit 1
php docker/bin/refresh-postgres-database.php || exit 1
Expand Down
8 changes: 4 additions & 4 deletions pkg/amqp-ext/AmqpConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(AmqpContext $context, InteropAmqpQueue $queue)
$this->flags = self::FLAG_NOPARAM;
}

public function setConsumerTag(string $consumerTag = null): void
public function setConsumerTag(?string $consumerTag = null): void
{
$this->consumerTag = $consumerTag;
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public function receive(int $timeout = 0): ?Message
return $message;
}

usleep(100000); //100ms
usleep(100000); // 100ms
}

return null;
Expand All @@ -118,7 +118,7 @@ public function acknowledge(Message $message): void
{
InvalidMessageException::assertMessageInstanceOf($message, InteropAmqpMessage::class);

$this->getExtQueue()->ack($message->getDeliveryTag());
$this->getExtQueue()->ack((int) $message->getDeliveryTag());
}

/**
Expand All @@ -130,7 +130,7 @@ public function reject(Message $message, bool $requeue = false): void

$this->getExtQueue()->reject(
$message->getDeliveryTag(),
$requeue ? AMQP_REQUEUE : AMQP_NOPARAM
$requeue ? \AMQP_REQUEUE : \AMQP_NOPARAM
);
}

Expand Down
9 changes: 3 additions & 6 deletions pkg/amqp-ext/AmqpContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function unbind(InteropAmqpBind $bind): void
public function createTemporaryQueue(): Queue
{
$extQueue = new \AMQPQueue($this->getExtChannel());
$extQueue->setFlags(AMQP_EXCLUSIVE);
$extQueue->setFlags(\AMQP_EXCLUSIVE);

$extQueue->declareQueue();

Expand Down Expand Up @@ -243,10 +243,7 @@ public function getExtChannel(): \AMQPChannel
if (false == $this->extChannel) {
$extChannel = call_user_func($this->extChannelFactory);
if (false == $extChannel instanceof \AMQPChannel) {
throw new \LogicException(sprintf(
'The factory must return instance of AMQPChannel. It returns %s',
is_object($extChannel) ? get_class($extChannel) : gettype($extChannel)
));
throw new \LogicException(sprintf('The factory must return instance of AMQPChannel. It returns %s', is_object($extChannel) ? get_class($extChannel) : gettype($extChannel)));
}

$this->extChannel = $extChannel;
Expand Down Expand Up @@ -278,7 +275,7 @@ public function convertMessage(\AMQPEnvelope $extEnvelope): InteropAmqpMessage
]
);
$message->setRedelivered($extEnvelope->isRedelivery());
$message->setDeliveryTag($extEnvelope->getDeliveryTag());
$message->setDeliveryTag((int) $extEnvelope->getDeliveryTag());
$message->setRoutingKey($extEnvelope->getRoutingKey());

return $message;
Expand Down
16 changes: 8 additions & 8 deletions pkg/async-command/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
"php": "^7.4|^8.0",
"enqueue/enqueue": "^0.10",
"queue-interop/queue-interop": "^0.8",
"symfony/console": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0"
"symfony/console": "^5.4|^6.4|^7.0",
"symfony/process": "^5.4|^6.4|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/filesystem": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.4|^7.0",
"symfony/config": "^5.4|^6.4|^7.0",
"symfony/http-kernel": "^5.4|^6.4|^7.0",
"symfony/filesystem": "^5.4|^6.4|^7.0",
"symfony/yaml": "^5.4|^6.4|^7.0",
"enqueue/null": "0.10.x-dev",
"enqueue/fs": "0.10.x-dev",
"enqueue/test": "0.10.x-dev"
Expand All @@ -31,7 +31,7 @@
"docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md"
},
"suggest": {
"symfony/dependency-injection": "^5.4|^6.0 If you'd like to use async event dispatcher container extension."
"symfony/dependency-injection": "^5.4|^6.4|^7.0 If you'd like to use async event dispatcher container extension."
},
"autoload": {
"psr-4": { "Enqueue\\AsyncCommand\\": "" },
Expand Down
33 changes: 15 additions & 18 deletions pkg/async-event-dispatcher/ContainerAwareRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace Enqueue\AsyncEventDispatcher;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Psr\Container\ContainerInterface;

class ContainerAwareRegistry implements Registry, ContainerAwareInterface
class ContainerAwareRegistry implements Registry
{
use ContainerAwareTrait;

/**
* @var string[]
*/
Expand All @@ -19,6 +16,8 @@ class ContainerAwareRegistry implements Registry, ContainerAwareInterface
*/
private $transformersMap;

private ContainerInterface $container;

/**
* @param string[] $eventsMap [eventName => transformerName]
* @param string[] $transformersMap [transformerName => transformerServiceId]
Expand All @@ -29,9 +28,6 @@ public function __construct(array $eventsMap, array $transformersMap)
$this->transformersMap = $transformersMap;
}

/**
* {@inheritdoc}
*/
public function getTransformerNameForEvent($eventName)
{
$transformerName = null;
Expand All @@ -58,25 +54,26 @@ public function getTransformerNameForEvent($eventName)
return $transformerName;
}

/**
* {@inheritdoc}
*/
public function getTransformer($name)
{
if (false == array_key_exists($name, $this->transformersMap)) {
if (!array_key_exists($name, $this->transformersMap)) {
throw new \LogicException(sprintf('There is no transformer named %s', $name));
}

$transformer = $this->container->get($this->transformersMap[$name]);

if (false == $transformer instanceof EventTransformer) {
throw new \LogicException(sprintf(
'The container must return instance of %s but got %s',
EventTransformer::class,
is_object($transformer) ? get_class($transformer) : gettype($transformer)
));
if (!$transformer instanceof EventTransformer) {
throw new \LogicException(sprintf('The container must return instance of %s but got %s', EventTransformer::class, is_object($transformer) ? get_class($transformer) : gettype($transformer)));
}

return $transformer;
}

/**
* @required
*/
public function setContainer(ContainerInterface $container)
{
$this->container = $container;
}
}
14 changes: 7 additions & 7 deletions pkg/async-event-dispatcher/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
"php": "^7.4|^8.0",
"enqueue/enqueue": "^0.10",
"queue-interop/queue-interop": "^0.8",
"symfony/event-dispatcher": "^5.4|^6.0"
"symfony/event-dispatcher": "^5.4|^6.4|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/filesystem": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.4|^7.0",
"symfony/config": "^5.4|^6.4|^7.0",
"symfony/http-kernel": "^5.4|^6.4|^7.0",
"symfony/filesystem": "^5.4|^6.4|^7.0",
"symfony/yaml": "^5.4|^6.4|^7.0",
"enqueue/null": "0.10.x-dev",
"enqueue/fs": "0.10.x-dev",
"enqueue/test": "0.10.x-dev"
Expand All @@ -30,7 +30,7 @@
"docs": "https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md"
},
"suggest": {
"symfony/dependency-injection": "^5.4|^6.0 If you'd like to use async event dispatcher container extension."
"symfony/dependency-injection": "^5.4|^6.4|^7.0 If you'd like to use async event dispatcher container extension."
},
"autoload": {
"psr-4": { "Enqueue\\AsyncEventDispatcher\\": "" },
Expand Down
12 changes: 6 additions & 6 deletions pkg/enqueue-bundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"require": {
"php": "^7.4|^8.0",
"symfony/framework-bundle": "^5.4|^6.0",
"symfony/framework-bundle": "^5.4|^6.4|^7.0",
"queue-interop/amqp-interop": "^0.8.2",
"queue-interop/queue-interop": "^0.8",
"enqueue/enqueue": "^0.10",
Expand Down Expand Up @@ -37,12 +37,12 @@
"enqueue/async-command": "0.10.x-dev",
"php-amqplib/php-amqplib": "^3.0",
"doctrine/doctrine-bundle": "^2.3.2",
"doctrine/mongodb-odm-bundle": "^3.5|^4.3",
"doctrine/mongodb-odm-bundle": "^3.5|^4.3|^5.0",
"alcaeus/mongo-php-adapter": "^1.0",
"symfony/browser-kit": "^5.4|^6.0",
"symfony/expression-language": "^5.4|^6.0",
"symfony/validator": "^5.4|^6.0",
"symfony/yaml": "^5.4|^6.0"
"symfony/browser-kit": "^5.4|^6.4|^7.0",
"symfony/expression-language": "^5.4|^6.4|^7.0",
"symfony/validator": "^5.4|^6.4|^7.0",
"symfony/yaml": "^5.4|^6.4|^7.0"
},
"suggest": {
"enqueue/async-command": "If want to run Symfony command via message queue",
Expand Down
Loading

0 comments on commit cf09d11

Please sign in to comment.