diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0a4dd2efe..0958ff52b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -68,6 +68,26 @@ jobs: can-fail: false symfony-require: "7.0.*" remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later + - php-version: "8.3" + composer-flags: "" + can-fail: false + symfony-require: "7.0.*" + remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later + - php-version: "8.4" + composer-flags: "" + can-fail: false + symfony-require: "7.0.*" + remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later + - php-version: "8.4" + composer-flags: "" + can-fail: false + symfony-require: "7.4.*" + remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later + - php-version: "8.4" + composer-flags: "" + can-fail: false + symfony-require: "8.0.*" + remove-sensio-bundle: yes # SensioFrameworkExtraBundle is not compatible with Symfony 7.0 or later - php-version: "8.3" composer-flags: "" can-fail: true # we don't want to fail the build if we are incompatible with the next (unstable) Symfony version diff --git a/EventListener/AllowedMethodsListener.php b/EventListener/AllowedMethodsListener.php index fa88c8a78..ca10b141e 100644 --- a/EventListener/AllowedMethodsListener.php +++ b/EventListener/AllowedMethodsListener.php @@ -41,10 +41,10 @@ public function onKernelResponse(ResponseEvent $event): void $allowedMethods = $this->loader->getAllowedMethods(); - if (isset($allowedMethods[$event->getRequest()->get('_route')])) { + if (isset($allowedMethods[$event->getRequest()->attributes->get('_route')])) { $event->getResponse() ->headers - ->set('Allow', implode(', ', $allowedMethods[$event->getRequest()->get('_route')])); + ->set('Allow', implode(', ', $allowedMethods[$event->getRequest()->attributes->get('_route')])); } } } diff --git a/Tests/Controller/Annotations/AbstractScalarParamTest.php b/Tests/Controller/Annotations/AbstractScalarParamTest.php index 03e7391f6..1db1e7e4a 100644 --- a/Tests/Controller/Annotations/AbstractScalarParamTest.php +++ b/Tests/Controller/Annotations/AbstractScalarParamTest.php @@ -80,10 +80,10 @@ public function testScalarRequirements() $this->param->requirements = 'foo %bar% %%'; $this->assertEquals([ new NotNull(), - new Regex([ - 'pattern' => '#^(?:foo %bar% %%)$#xsu', - 'message' => "Parameter 'bar' value, does not match requirements 'foo %bar% %%'", - ]), + new Regex( + '#^(?:foo %bar% %%)$#xsu', + "Parameter 'bar' value, does not match requirements 'foo %bar% %%'", + ), ], $this->param->getConstraints()); } @@ -95,10 +95,10 @@ public function testArrayRequirements() ]; $this->assertEquals([ new NotNull(), - new Regex([ - 'pattern' => '#^(?:foo)$#xsu', - 'message' => 'bar', - ]), + new Regex( + '#^(?:foo)$#xsu', + 'bar', + ), ], $this->param->getConstraints()); } diff --git a/Tests/Fixtures/Annotations/IdenticalToRequestParam.php b/Tests/Fixtures/Annotations/IdenticalToRequestParam.php index 45b1f97e9..0935c605f 100644 --- a/Tests/Fixtures/Annotations/IdenticalToRequestParam.php +++ b/Tests/Fixtures/Annotations/IdenticalToRequestParam.php @@ -11,6 +11,7 @@ namespace FOS\RestBundle\Tests\Fixtures\Annotations; +use Composer\InstalledVersions; use FOS\RestBundle\Controller\Annotations\RequestParam; use Symfony\Component\Validator\Constraints\IdenticalTo; @@ -41,6 +42,21 @@ public function __construct( bool $nullable = false, bool $allowBlank = true ) { - parent::__construct($name, $key, null !== $identicalTo ? new IdenticalTo($identicalTo) : null, $default, $description, $incompatibles, $strict, $map, $nullable, $allowBlank); + $validatorSupportsArrayConfig = true; + if (class_exists(InstalledVersions::class)) { + $validatorVersion = InstalledVersions::getVersion('symfony/validator'); + + $validatorSupportsArrayConfig = version_compare($validatorVersion, '8.0', '<'); + } + + if (null === $identicalTo) { + $options = null; + } elseif ($validatorSupportsArrayConfig) { + $options = $identicalTo; + } else { + $options = $identicalTo['value']; + } + + parent::__construct($name, $key, null !== $options ? new IdenticalTo($options) : null, $default, $description, $incompatibles, $strict, $map, $nullable, $allowBlank); } } diff --git a/composer.json b/composer.json index 9738ffaca..f60a63f2f 100644 --- a/composer.json +++ b/composer.json @@ -31,14 +31,14 @@ "require": { "php": "^7.4|^8.0", "symfony/config": "^5.4|^6.4|^7.0", - "symfony/dependency-injection": "^5.4|^6.4|^7.0", + "symfony/dependency-injection": "^5.4|^6.4|^7.0|^8.0", "symfony/deprecation-contracts": "^2.1|^3.0", - "symfony/event-dispatcher": "^5.4|^6.4|^7.0", - "symfony/framework-bundle": "^5.4|^6.4|^7.0", - "symfony/http-foundation": "^5.4|^6.4|^7.0", - "symfony/http-kernel": "^5.4|^6.4|^7.0", - "symfony/routing": "^5.4|^6.4|^7.0", - "symfony/security-core": "^5.4|^6.4|^7.0", + "symfony/event-dispatcher": "^5.4|^6.4|^7.0|^8.0", + "symfony/framework-bundle": "^5.4|^6.4|^7.0|^8.0", + "symfony/http-foundation": "^5.4|^6.4|^7.0|^8.0", + "symfony/http-kernel": "^5.4|^6.4|^7.0|^8.0", + "symfony/routing": "^5.4|^6.4|^7.0|^8.0", + "symfony/security-core": "^5.4|^6.4|^7.0|^8.0", "willdurand/jsonp-callback-validator": "^1.0|^2.0", "willdurand/negotiation": "^2.0|^3.0" }, @@ -50,19 +50,19 @@ "psr/http-message": "^1.0", "psr/log": "^1.0|^2.0|^3.0", "sensio/framework-extra-bundle": "^6.1", - "symfony/asset": "^5.4|^6.4|^7.0", - "symfony/browser-kit": "^5.4|^6.4|^7.0", - "symfony/css-selector": "^5.4|^6.4|^7.0", - "symfony/expression-language": "^5.4|^6.4|^7.0", - "symfony/form": "^5.4|^6.4|^7.0", - "symfony/mime": "^5.4|^6.4|^7.0", - "symfony/phpunit-bridge": "^7.0.1", - "symfony/security-bundle": "^5.4|^6.4|^7.0", - "symfony/serializer": "^5.4|^6.4|^7.0", - "symfony/twig-bundle": "^5.4|^6.4|^7.0", - "symfony/validator": "^5.4|^6.4|^7.0", - "symfony/web-profiler-bundle": "^5.4|^6.4|^7.0", - "symfony/yaml": "^5.4|^6.4|^7.0" + "symfony/asset": "^5.4|^6.4|^7.0|^8.0", + "symfony/browser-kit": "^5.4|^6.4|^7.0|^8.0", + "symfony/css-selector": "^5.4|^6.4|^7.0|^8.0", + "symfony/expression-language": "^5.4|^6.4|^7.0|^8.0", + "symfony/form": "^5.4|^6.4|^7.0|^8.0", + "symfony/mime": "^5.4|^6.4|^7.0|^8.0", + "symfony/phpunit-bridge": "^7.0.1|^8.0", + "symfony/security-bundle": "^5.4|^6.4|^7.0|^8.0", + "symfony/serializer": "^5.4|^6.4|^7.0|^8.0", + "symfony/twig-bundle": "^5.4|^6.4|^7.0|^8.0", + "symfony/validator": "^5.4|^6.4|^7.0|^8.0", + "symfony/web-profiler-bundle": "^5.4|^6.4|^7.0|^8.0", + "symfony/yaml": "^5.4|^6.4|^7.0|^8.0" }, "suggest": { "jms/serializer-bundle": "Add support for advanced serialization capabilities, recommended",