Skip to content

Commit e2f5d3f

Browse files
DimaSorokinDima Sorokinandrew-demb
authored
Add support for Symfony 8 (#744)
* Add support for Symfony 8.x - Update composer.json to allow Symfony 8 components - Test compatibility with Symfony 8.0 * Fix README.md Co-authored-by: Andrii Dembitskyi <andrew.dembitskiy@gmail.com> * Add Symfony 8 support and fix CI matrix for valid PHP/Symfony combinations * Fix MessageDataCollector type hint issue by using dedicated property --------- Co-authored-by: Dima Sorokin <sorokin.d@rozetka.ua> Co-authored-by: Andrii Dembitskyi <andrew.dembitskiy@gmail.com>
1 parent 64fe6d4 commit e2f5d3f

File tree

5 files changed

+59
-28
lines changed

5 files changed

+59
-28
lines changed

.github/workflows/test.yaml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,26 @@ jobs:
1010

1111
strategy:
1212
matrix:
13-
php-version: ['8.2', '8.3', '8.4', '8.5']
14-
symfony-version: ['6.4', '7.4']
15-
coverage: ['none']
16-
include:
17-
- php-version: '8.3'
18-
symfony-version: '6.4'
19-
coverage: xdebug
13+
include:
14+
- php-version: '8.2'
15+
symfony-version: '6.4'
16+
coverage: none
17+
18+
- php-version: '8.3'
19+
symfony-version: '7.4'
20+
coverage: none
21+
22+
- php-version: '8.4'
23+
symfony-version: '8.0'
24+
coverage: none
25+
26+
- php-version: '8.4'
27+
symfony-version: '7.4'
28+
coverage: none
29+
30+
- php-version: '8.3'
31+
symfony-version: '6.4'
32+
coverage: xdebug
2033

2134
steps:
2235
- name: Checkout
@@ -34,7 +47,7 @@ jobs:
3447
run: composer validate --no-check-lock
3548

3649
- name: Install Composer dependencies
37-
uses: ramsey/composer-install@v1
50+
uses: ramsey/composer-install@v2
3851
with:
3952
composer-options: "--prefer-dist"
4053
env:

.scrutinizer.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
build:
2+
environment:
3+
php:
4+
version: 8.2
25
dependencies:
36
before:
47
- composer config minimum-stability RC
8+
override:
9+
- composer install --prefer-dist --no-interaction
510
nodes:
611
analysis:
712
tests:

DataCollector/MessageDataCollector.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,41 @@ class MessageDataCollector extends DataCollector
1515
{
1616
private $channels;
1717

18+
/** @var array */
19+
private $messages;
20+
1821
public function __construct($channels)
1922
{
2023
$this->channels = $channels;
21-
$this->data = [];
24+
$this->messages = [];
2225
}
2326

24-
public function collect(Request $request, Response $response, ?\Throwable $exception = null)
27+
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
2528
{
2629
foreach ($this->channels as $channel) {
2730
foreach ($channel->getBasicPublishLog() as $log) {
28-
$this->data[] = $log;
31+
$this->messages[] = $log;
2932
}
3033
}
3134
}
3235

33-
public function getName()
36+
public function getName(): string
3437
{
3538
return 'rabbit_mq';
3639
}
3740

38-
public function getPublishedMessagesCount()
41+
public function getPublishedMessagesCount(): int
3942
{
40-
return count($this->data);
43+
return count($this->messages);
4144
}
4245

43-
public function getPublishedMessagesLog()
46+
public function getPublishedMessagesLog(): array
4447
{
45-
return $this->data;
48+
return $this->messages;
4649
}
4750

48-
public function reset()
51+
public function reset(): void
4952
{
50-
$this->data = [];
53+
$this->messages = [];
5154
}
5255
}

Tests/Command/SetupFabricCommandTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ public function testExecute(): void
5454
$command->setContainer($container);
5555

5656
// TODO: Use addCommand() once Symfony Support for < 7.4 is dropped
57-
$application->add($command);
57+
if (method_exists($application, 'addCommand')) {
58+
$application->addCommand($command);
59+
} else {
60+
// @phpstan-ignore-next-line
61+
$application->add($command);
62+
}
5863

5964
$registeredCommand = $application->find('rabbitmq:setup-fabric');
6065

@@ -102,7 +107,12 @@ public function testExecute_withSkipAnonConsumers(): void
102107
$command->setContainer($container);
103108

104109
// TODO: Use addCommand() once Symfony Support for < 7.4 is dropped
105-
$application->add($command);
110+
if (method_exists($application, 'addCommand')) {
111+
$application->addCommand($command);
112+
} else {
113+
// @phpstan-ignore-next-line
114+
$application->add($command);
115+
}
106116

107117
$registeredCommand = $application->find('rabbitmq:setup-fabric');
108118

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
}],
1010
"require": {
1111
"php": "^8.2",
12-
"symfony/dependency-injection": "^6.0 || ^7.0",
13-
"symfony/event-dispatcher": "^6.0 || ^7.0",
14-
"symfony/config": "^6.0 || ^7.0",
15-
"symfony/yaml": "^6.0 || ^7.0",
16-
"symfony/console": "^6.0 || ^7.0",
12+
"symfony/dependency-injection": "^6.0 || ^7.0 || ^8.0",
13+
"symfony/event-dispatcher": "^6.0 || ^7.0 || ^8.0",
14+
"symfony/config": "^6.0 || ^7.0 || ^8.0",
15+
"symfony/yaml": "^6.0 || ^7.0 || ^8.0",
16+
"symfony/console": "^6.0 || ^7.0 || ^8.0",
1717
"php-amqplib/php-amqplib": "^2.12.2 || ^3.0",
1818
"psr/log": "^2.0 || ^3.0",
19-
"symfony/http-kernel": "^6.0 || ^7.0",
20-
"symfony/framework-bundle": "^6.0 || ^7.0"
19+
"symfony/http-kernel": "^6.0 || ^7.0 || ^8.0",
20+
"symfony/framework-bundle": "^6.0 || ^7.0 || ^8.0"
2121
},
2222
"require-dev": {
23-
"symfony/serializer": "^6.0 || ^7.0",
23+
"symfony/serializer": "^6.0 || ^7.0 || ^8.0",
2424
"phpunit/phpunit": "^9.5",
2525
"phpstan/phpstan": "^1.2",
2626
"phpstan/phpstan-phpunit": "^1.0"

0 commit comments

Comments
 (0)