diff --git a/src/PropertyDescriber/PropertyDescriber.php b/src/PropertyDescriber/PropertyDescriber.php index 03793ae1b..d18e480b0 100644 --- a/src/PropertyDescriber/PropertyDescriber.php +++ b/src/PropertyDescriber/PropertyDescriber.php @@ -71,11 +71,6 @@ private function getHash(array $types): string private function getPropertyDescriber(array $types, array $context): ?PropertyDescriberInterface { foreach ($this->propertyDescribers as $propertyDescriber) { - /* BC layer for Symfony < 6.3 @see https://symfony.com/doc/6.3/service_container/tags.html#reference-tagged-services */ - if ($propertyDescriber instanceof self) { - continue; - } - // Prevent infinite recursion if (\array_key_exists($this->getHash($types), $this->called)) { if (\in_array($propertyDescriber, $this->called[$this->getHash($types)], true)) { diff --git a/tests/Functional/ControllerTest.php b/tests/Functional/ControllerTest.php index 01e6e7276..b09da5001 100644 --- a/tests/Functional/ControllerTest.php +++ b/tests/Functional/ControllerTest.php @@ -79,12 +79,10 @@ public function testControllers(?array $controller, ?string $fixtureName = null, public static function provideAttributeTestCases(): \Generator { - $type = Kernel::MAJOR_VERSION === 5 ? 'annotation' : 'attribute'; - yield 'Promoted properties defaults attributes' => [ [ 'name' => 'PromotedPropertiesController81', - 'type' => $type, + 'type' => 'attribute', ], 'PromotedPropertiesDefaults', [], @@ -94,78 +92,78 @@ public static function provideAttributeTestCases(): \Generator yield 'JMS model opt out' => [ [ 'name' => 'JmsOptOutController', - 'type' => $type, + 'type' => 'attribute', ], 'JmsOptOutController', [new JMSSerializerBundle()], [__DIR__.'/Configs/JMS.yaml'], ]; - if (version_compare(Kernel::VERSION, '6.3.0', '>=')) { - yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2209' => [ - [ - 'name' => 'Controller2209', - 'type' => $type, - ], - ]; - yield 'MapQueryString' => [ - [ - 'name' => 'MapQueryStringController', - 'type' => $type, - null, - [], - [__DIR__.'/Configs/EnableSerializer.yaml'], - ], - ]; - yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2191' => [ - [ - 'name' => 'MapQueryStringController', - 'type' => $type, - ], - 'MapQueryStringCleanupComponents', - [], - [__DIR__.'/Configs/CleanUnusedComponentsProcessor.yaml', __DIR__.'/Configs/EnableSerializer.yaml'], - ]; - - yield 'operationId must always be generated' => [ - [ - 'name' => 'OperationIdController', - 'type' => $type, - ], - ]; - - yield 'Symfony 6.3 MapQueryParameter attribute' => [ - [ - 'name' => 'MapQueryParameterController', - 'type' => $type, - ], - ]; + yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2209' => [ + [ + 'name' => 'Controller2209', + 'type' => 'attribute', + ], + ]; - yield 'Symfony 6.3 MapRequestPayload attribute' => [ - [ - 'name' => 'MapRequestPayloadController', - 'type' => $type, - ], + yield 'MapQueryString' => [ + [ + 'name' => 'MapQueryStringController', + 'type' => 'attribute', null, [], [__DIR__.'/Configs/EnableSerializer.yaml'], - ]; + ], + ]; + + yield 'https://github.com/nelmio/NelmioApiDocBundle/issues/2191' => [ + [ + 'name' => 'MapQueryStringController', + 'type' => 'attribute', + ], + 'MapQueryStringCleanupComponents', + [], + [__DIR__.'/Configs/CleanUnusedComponentsProcessor.yaml', __DIR__.'/Configs/EnableSerializer.yaml'], + ]; + + yield 'operationId must always be generated' => [ + [ + 'name' => 'OperationIdController', + 'type' => 'attribute', + ], + ]; + + yield 'Symfony 6.3 MapQueryParameter attribute' => [ + [ + 'name' => 'MapQueryParameterController', + 'type' => 'attribute', + ], + ]; + + yield 'Symfony 6.3 MapRequestPayload attribute' => [ + [ + 'name' => 'MapRequestPayloadController', + 'type' => 'attribute', + ], + null, + [], + [__DIR__.'/Configs/EnableSerializer.yaml'], + ]; - yield 'Create top level Tag from Tag attribute' => [ + yield 'Create top level Tag from Tag attribute' => [ + [ + 'name' => 'OpenApiTagController', + 'type' => 'attribute', + ], + ]; + + if (property_exists(MapRequestPayload::class, 'type')) { + yield 'Symfony 7.1 MapRequestPayload array type' => [ [ - 'name' => 'OpenApiTagController', - 'type' => $type, + 'name' => 'MapRequestPayloadArray', + 'type' => 'attribute', ], ]; - - if (property_exists(MapRequestPayload::class, 'type')) { - yield 'Symfony 7.1 MapRequestPayload array type' => [ - [ - 'name' => 'MapRequestPayloadArray', - 'type' => $type, - ], - ]; - } } } diff --git a/tests/Functional/Entity/RangeInteger.php b/tests/Functional/Entity/RangeInteger.php index c41488d6f..a3c4b1527 100644 --- a/tests/Functional/Entity/RangeInteger.php +++ b/tests/Functional/Entity/RangeInteger.php @@ -13,8 +13,6 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; -use Symfony\Component\HttpKernel\Kernel; - trait RangeIntegerTrait { /** @@ -38,24 +36,17 @@ trait RangeIntegerTrait public $nullableRangeInt; } -if (version_compare(Kernel::VERSION, '6.1', '>=')) { - class RangeInteger - { - use RangeIntegerTrait; - - /** - * @var positive-int - */ - public $positiveInt; - - /** - * @var negative-int - */ - public $negativeInt; - } -} else { - class RangeInteger - { - use RangeIntegerTrait; - } +class RangeInteger +{ + use RangeIntegerTrait; + + /** + * @var positive-int + */ + public $positiveInt; + + /** + * @var negative-int + */ + public $negativeInt; } diff --git a/tests/Functional/FOSRestTest.php b/tests/Functional/FOSRestTest.php index 205d18d55..5c449947b 100644 --- a/tests/Functional/FOSRestTest.php +++ b/tests/Functional/FOSRestTest.php @@ -80,10 +80,8 @@ public function testFOSRestAction(string $route): void public static function provideRoute(): \Generator { - yield 'Annotations' => ['/api/fosrest']; + yield ['/api/fosrest']; - if (TestKernel::isAttributesAvailable()) { - yield 'Attributes' => ['/api/fosrest_attributes']; - } + yield ['/api/fosrest_attributes']; } } diff --git a/tests/Functional/FunctionalTest.php b/tests/Functional/FunctionalTest.php index 2f1481c37..455d040b8 100644 --- a/tests/Functional/FunctionalTest.php +++ b/tests/Functional/FunctionalTest.php @@ -16,7 +16,6 @@ use OpenApi\Attributes as OAAttributes; use OpenApi\Generator; use PHPUnit\Framework\Attributes\DataProvider; -use Symfony\Component\HttpKernel\Kernel; class FunctionalTest extends WebTestCase { @@ -1234,19 +1233,17 @@ public function testRangeIntegers(): void 'type' => 'object', ]; - if (version_compare(Kernel::VERSION, '6.1', '>=')) { - array_unshift($expected['required'], 'positiveInt', 'negativeInt'); - $expected['properties'] += [ - 'positiveInt' => [ - 'type' => 'integer', - 'minimum' => 1, - ], - 'negativeInt' => [ - 'type' => 'integer', - 'maximum' => -1, - ], - ]; - } + array_unshift($expected['required'], 'positiveInt', 'negativeInt'); + $expected['properties'] += [ + 'positiveInt' => [ + 'type' => 'integer', + 'minimum' => 1, + ], + 'negativeInt' => [ + 'type' => 'integer', + 'maximum' => -1, + ], + ]; self::assertEquals($expected, json_decode($this->getModel('RangeInteger')->toJson(), true)); } diff --git a/tests/Functional/JMSFunctionalTest.php b/tests/Functional/JMSFunctionalTest.php index a8834fef4..73dc49eb7 100644 --- a/tests/Functional/JMSFunctionalTest.php +++ b/tests/Functional/JMSFunctionalTest.php @@ -380,11 +380,6 @@ public function testEnumSupport(): void ], ], json_decode($this->getModel('ArticleType81')->toJson(), true)); - if (TestKernel::isAnnotationsAvailable()) { - // Further tests have only been defined with attributes - return; - } - self::assertEquals([ 'schema' => 'ArticleType812', 'type' => 'string', diff --git a/tests/Functional/ModelDescriber/ObjectModelDescriberTest.php b/tests/Functional/ModelDescriber/ObjectModelDescriberTest.php index c1a2d0c84..ab0b435d2 100644 --- a/tests/Functional/ModelDescriber/ObjectModelDescriberTest.php +++ b/tests/Functional/ModelDescriber/ObjectModelDescriberTest.php @@ -18,7 +18,6 @@ use Nelmio\ApiDocBundle\Tests\Functional\WebTestCase; use OpenApi\Annotations as OA; use OpenApi\Annotations\OpenApi; -use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\PropertyInfo\Type as LegacyType; class ObjectModelDescriberTest extends WebTestCase @@ -92,11 +91,9 @@ public static function provideFixtures(): \Generator Fixtures\ClassWithObject::class, ]; - if (\PHP_VERSION_ID >= 80100) { - yield [ - Fixtures\ClassWithIntersection::class, - ]; - } + yield [ + Fixtures\ClassWithIntersection::class, + ]; yield [ Fixtures\DateTimeClass::class, @@ -106,11 +103,9 @@ public static function provideFixtures(): \Generator Fixtures\UuidClass::class, ]; - if (version_compare(Kernel::VERSION, '6.4.0', '>=')) { - yield [ - Fixtures\UuidClass7And8::class, - ]; - } + yield [ + Fixtures\UuidClass7And8::class, + ]; yield [ Fixtures\Refs::class, diff --git a/tests/Functional/Resources/routes-attributes.yaml b/tests/Functional/Resources/routes-attributes.yaml deleted file mode 100644 index 7d131ab52..000000000 --- a/tests/Functional/Resources/routes-attributes.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Resources -test: - resource: ../Controller/TestController.php - type: attribute - -api: - resource: ../Controller/ApiController.php - type: attribute - -class_api: - resource: ../Controller/ClassApiController.php - type: attribute - -undocumented: - resource: ../Controller/UndocumentedController.php - type: attribute - -invokable: - resource: ../Controller/InvokableController.php - type: attribute - -api_platform: - resource: . - prefix: /api - type: api_platform - -# Controllers -doc_area: - path: /{area}/docs - controller: nelmio_api_doc.controller.swagger_ui - defaults: - area: default - -redocly_doc_area: - path: /{area}/redocly/docs - controller: nelmio_api_doc.controller.redocly - defaults: - area: default - -doc_json: - path: /{area}/docs.json - controller: nelmio_api_doc.controller.swagger_json - -doc_yaml: - path: /{area}/docs.yaml - controller: nelmio_api_doc.controller.swagger_yaml diff --git a/tests/Functional/Resources/routes.yaml b/tests/Functional/Resources/routes.yaml index 469d84bc0..f221309fe 100644 --- a/tests/Functional/Resources/routes.yaml +++ b/tests/Functional/Resources/routes.yaml @@ -1,24 +1,24 @@ # Resources test: resource: ../Controller/TestController.php - type: annotation + type: attribute api: resource: ../Controller/ApiController.php - type: annotation + type: attribute class_api: resource: ../Controller/ClassApiController.php - type: annotation - + type: attribute + undocumented: resource: ../Controller/UndocumentedController.php - type: annotation - + type: attribute + invokable: resource: ../Controller/InvokableController.php - type: annotation - + type: attribute + api_platform: resource: . prefix: /api @@ -28,7 +28,7 @@ api_platform: doc_area: path: /{area}/docs controller: nelmio_api_doc.controller.swagger_ui - defaults: + defaults: area: default redocly_doc_area: diff --git a/tests/Functional/TestKernel.php b/tests/Functional/TestKernel.php index 0533f5416..c68f07f9b 100644 --- a/tests/Functional/TestKernel.php +++ b/tests/Functional/TestKernel.php @@ -79,22 +79,18 @@ public function registerBundles(): iterable protected function configureRoutes(RoutingConfigurator $routes): void { - if (self::isAnnotationsAvailable()) { - $routes->withPath('/')->import(__DIR__.'/Resources/routes.yaml', 'yaml'); - } else { - $routes->withPath('/')->import(__DIR__.'/Resources/routes-attributes.yaml', 'yaml'); - } + $routes->withPath('/')->import(__DIR__.'/Resources/routes.yaml', 'yaml'); if (self::USE_JMS === $this->flag || self::USE_BAZINGA === $this->flag) { - $routes->withPath('/')->import(__DIR__.'/Controller/JMSController.php', self::isAnnotationsAvailable() ? 'annotation' : 'attribute'); + $routes->withPath('/')->import(__DIR__.'/Controller/JMSController.php', 'attribute'); } if (self::USE_BAZINGA === $this->flag) { - $routes->withPath('/')->import(__DIR__.'/Controller/BazingaTypedController.php', self::isAnnotationsAvailable() ? 'annotation' : 'attribute'); + $routes->withPath('/')->import(__DIR__.'/Controller/BazingaTypedController.php', 'attribute'); } if (self::USE_FOSREST === $this->flag) { - $routes->withPath('/')->import(__DIR__.'/Controller/FOSRestController.php', self::isAnnotationsAvailable() ? 'annotation' : 'attribute'); + $routes->withPath('/')->import(__DIR__.'/Controller/FOSRestController.php', 'attribute'); } } @@ -106,11 +102,8 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load 'test' => null, 'validation' => null, 'form' => null, - 'serializer' => ( - Kernel::MAJOR_VERSION < 7 - ? ['enable_annotations' => true] - : [] - ) + [ + 'serializer' => [ + 'enable_attributes' => true, 'mapping' => [ 'paths' => [__DIR__.'/Resources/serializer/'], ], @@ -320,22 +313,4 @@ public function getLogDir(): string { return parent::getLogDir().'/'.$this->flag; } - - public static function isAnnotationsAvailable(): bool - { - if (Kernel::MAJOR_VERSION <= 5) { - return true; - } - - if (Kernel::MAJOR_VERSION >= 7) { - return false; - } - - return false; - } - - public static function isAttributesAvailable(): bool - { - return true; - } } diff --git a/tests/Routing/FilteredRouteCollectionBuilderTest.php b/tests/Routing/FilteredRouteCollectionBuilderTest.php index 9bca7b5ed..36bc78321 100644 --- a/tests/Routing/FilteredRouteCollectionBuilderTest.php +++ b/tests/Routing/FilteredRouteCollectionBuilderTest.php @@ -140,9 +140,7 @@ public static function getMatchingRoutes(): \Generator ['r10', new Route('/api/areas/new'), ['path_patterns' => ['^/api']]], ]; - if (\PHP_VERSION_ID < 80000) { - yield ['r10', new Route('/api/areas_attributes/new'), ['path_patterns' => ['^/api']]]; - } + yield ['r10', new Route('/api/areas_attributes/new'), ['path_patterns' => ['^/api']]]; } /**