Skip to content

Commit bd9acb0

Browse files
authored
Merge pull request #2427 from W0rma/symfony8
Add support for symfony v8
2 parents c3be05f + ce7380c commit bd9acb0

File tree

5 files changed

+67
-31
lines changed

5 files changed

+67
-31
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@ jobs:
6868
can-fail: false
6969
symfony-require: "7.0.*"
7070
remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later
71+
- php-version: "8.3"
72+
composer-flags: ""
73+
can-fail: false
74+
symfony-require: "7.0.*"
75+
remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later
76+
- php-version: "8.4"
77+
composer-flags: ""
78+
can-fail: false
79+
symfony-require: "7.0.*"
80+
remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later
81+
- php-version: "8.4"
82+
composer-flags: ""
83+
can-fail: false
84+
symfony-require: "7.4.*"
85+
remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later
86+
- php-version: "8.4"
87+
composer-flags: ""
88+
can-fail: false
89+
symfony-require: "8.0.*"
90+
remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later
7191
- php-version: "8.3"
7292
composer-flags: ""
7393
can-fail: true # we don't want to fail the build if we are incompatible with the next (unstable) Symfony version

EventListener/AllowedMethodsListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function onKernelResponse(ResponseEvent $event): void
4141

4242
$allowedMethods = $this->loader->getAllowedMethods();
4343

44-
if (isset($allowedMethods[$event->getRequest()->get('_route')])) {
44+
if (isset($allowedMethods[$event->getRequest()->attributes->get('_route')])) {
4545
$event->getResponse()
4646
->headers
47-
->set('Allow', implode(', ', $allowedMethods[$event->getRequest()->get('_route')]));
47+
->set('Allow', implode(', ', $allowedMethods[$event->getRequest()->attributes->get('_route')]));
4848
}
4949
}
5050
}

Tests/Controller/Annotations/AbstractScalarParamTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public function testScalarRequirements()
8080
$this->param->requirements = 'foo %bar% %%';
8181
$this->assertEquals([
8282
new NotNull(),
83-
new Regex([
84-
'pattern' => '#^(?:foo %bar% %%)$#xsu',
85-
'message' => "Parameter 'bar' value, does not match requirements 'foo %bar% %%'",
86-
]),
83+
new Regex(
84+
'#^(?:foo %bar% %%)$#xsu',
85+
"Parameter 'bar' value, does not match requirements 'foo %bar% %%'",
86+
),
8787
], $this->param->getConstraints());
8888
}
8989

@@ -95,10 +95,10 @@ public function testArrayRequirements()
9595
];
9696
$this->assertEquals([
9797
new NotNull(),
98-
new Regex([
99-
'pattern' => '#^(?:foo)$#xsu',
100-
'message' => 'bar',
101-
]),
98+
new Regex(
99+
'#^(?:foo)$#xsu',
100+
'bar',
101+
),
102102
], $this->param->getConstraints());
103103
}
104104

Tests/Fixtures/Annotations/IdenticalToRequestParam.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace FOS\RestBundle\Tests\Fixtures\Annotations;
1313

14+
use Composer\InstalledVersions;
1415
use FOS\RestBundle\Controller\Annotations\RequestParam;
1516
use Symfony\Component\Validator\Constraints\IdenticalTo;
1617

@@ -41,6 +42,21 @@ public function __construct(
4142
bool $nullable = false,
4243
bool $allowBlank = true
4344
) {
44-
parent::__construct($name, $key, null !== $identicalTo ? new IdenticalTo($identicalTo) : null, $default, $description, $incompatibles, $strict, $map, $nullable, $allowBlank);
45+
$validatorSupportsArrayConfig = true;
46+
if (class_exists(InstalledVersions::class)) {
47+
$validatorVersion = InstalledVersions::getVersion('symfony/validator');
48+
49+
$validatorSupportsArrayConfig = version_compare($validatorVersion, '8.0', '<');
50+
}
51+
52+
if (null === $identicalTo) {
53+
$options = null;
54+
} elseif ($validatorSupportsArrayConfig) {
55+
$options = $identicalTo;
56+
} else {
57+
$options = $identicalTo['value'];
58+
}
59+
60+
parent::__construct($name, $key, null !== $options ? new IdenticalTo($options) : null, $default, $description, $incompatibles, $strict, $map, $nullable, $allowBlank);
4561
}
4662
}

composer.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"require": {
3232
"php": "^7.4|^8.0",
3333
"symfony/config": "^5.4|^6.4|^7.0",
34-
"symfony/dependency-injection": "^5.4|^6.4|^7.0",
34+
"symfony/dependency-injection": "^5.4|^6.4|^7.0|^8.0",
3535
"symfony/deprecation-contracts": "^2.1|^3.0",
36-
"symfony/event-dispatcher": "^5.4|^6.4|^7.0",
37-
"symfony/framework-bundle": "^5.4|^6.4|^7.0",
38-
"symfony/http-foundation": "^5.4|^6.4|^7.0",
39-
"symfony/http-kernel": "^5.4|^6.4|^7.0",
40-
"symfony/routing": "^5.4|^6.4|^7.0",
41-
"symfony/security-core": "^5.4|^6.4|^7.0",
36+
"symfony/event-dispatcher": "^5.4|^6.4|^7.0|^8.0",
37+
"symfony/framework-bundle": "^5.4|^6.4|^7.0|^8.0",
38+
"symfony/http-foundation": "^5.4|^6.4|^7.0|^8.0",
39+
"symfony/http-kernel": "^5.4|^6.4|^7.0|^8.0",
40+
"symfony/routing": "^5.4|^6.4|^7.0|^8.0",
41+
"symfony/security-core": "^5.4|^6.4|^7.0|^8.0",
4242
"willdurand/jsonp-callback-validator": "^1.0|^2.0",
4343
"willdurand/negotiation": "^2.0|^3.0"
4444
},
@@ -50,19 +50,19 @@
5050
"psr/http-message": "^1.0",
5151
"psr/log": "^1.0|^2.0|^3.0",
5252
"sensio/framework-extra-bundle": "^6.1",
53-
"symfony/asset": "^5.4|^6.4|^7.0",
54-
"symfony/browser-kit": "^5.4|^6.4|^7.0",
55-
"symfony/css-selector": "^5.4|^6.4|^7.0",
56-
"symfony/expression-language": "^5.4|^6.4|^7.0",
57-
"symfony/form": "^5.4|^6.4|^7.0",
58-
"symfony/mime": "^5.4|^6.4|^7.0",
59-
"symfony/phpunit-bridge": "^7.0.1",
60-
"symfony/security-bundle": "^5.4|^6.4|^7.0",
61-
"symfony/serializer": "^5.4|^6.4|^7.0",
62-
"symfony/twig-bundle": "^5.4|^6.4|^7.0",
63-
"symfony/validator": "^5.4|^6.4|^7.0",
64-
"symfony/web-profiler-bundle": "^5.4|^6.4|^7.0",
65-
"symfony/yaml": "^5.4|^6.4|^7.0"
53+
"symfony/asset": "^5.4|^6.4|^7.0|^8.0",
54+
"symfony/browser-kit": "^5.4|^6.4|^7.0|^8.0",
55+
"symfony/css-selector": "^5.4|^6.4|^7.0|^8.0",
56+
"symfony/expression-language": "^5.4|^6.4|^7.0|^8.0",
57+
"symfony/form": "^5.4|^6.4|^7.0|^8.0",
58+
"symfony/mime": "^5.4|^6.4|^7.0|^8.0",
59+
"symfony/phpunit-bridge": "^7.0.1|^8.0",
60+
"symfony/security-bundle": "^5.4|^6.4|^7.0|^8.0",
61+
"symfony/serializer": "^5.4|^6.4|^7.0|^8.0",
62+
"symfony/twig-bundle": "^5.4|^6.4|^7.0|^8.0",
63+
"symfony/validator": "^5.4|^6.4|^7.0|^8.0",
64+
"symfony/web-profiler-bundle": "^5.4|^6.4|^7.0|^8.0",
65+
"symfony/yaml": "^5.4|^6.4|^7.0|^8.0"
6666
},
6767
"suggest": {
6868
"jms/serializer-bundle": "Add support for advanced serialization capabilities, recommended",

0 commit comments

Comments
 (0)