diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 0ce63c679..aa61f6d76 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -19,4 +19,7 @@ public int $negative; ``` This causes the following breaking changes in classes that used on annotations: -- BC BREAK: Removed 3rd parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\Describer\OpenApiPhpDescriber::__construct()` \ No newline at end of file +- BC BREAK: Removed 3rd parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\Describer\OpenApiPhpDescriber::__construct()` +- BC BREAK: Removed 2nd parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\ModelDescriber\FormModelDescriber::__construct()` +- BC BREAK: Removed 2nd parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\ModelDescriber\JMSModelDescriber::__construct()` +- BC BREAK: Removed 2nd parameter `?Reader $annotationReader` from `Nelmio\ApiDocBundle\ModelDescriber\ObjectModelDescriber::__construct()` diff --git a/config/services.xml b/config/services.xml index be9c3cc56..5b2b80d35 100644 --- a/config/services.xml +++ b/config/services.xml @@ -82,7 +82,6 @@ - diff --git a/src/DependencyInjection/Compiler/ConfigurationPass.php b/src/DependencyInjection/Compiler/ConfigurationPass.php index d6d2a9edb..e15a02dd6 100644 --- a/src/DependencyInjection/Compiler/ConfigurationPass.php +++ b/src/DependencyInjection/Compiler/ConfigurationPass.php @@ -14,7 +14,6 @@ use Nelmio\ApiDocBundle\ModelDescriber\FormModelDescriber; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Reference; /** @@ -30,7 +29,6 @@ public function process(ContainerBuilder $container): void $container->register('nelmio_api_doc.model_describers.form', FormModelDescriber::class) ->setPublic(false) ->addArgument(new Reference('form.factory')) - ->addArgument(new Reference('annotations.reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)) ->addArgument($container->getParameter('nelmio_api_doc.media_types')) ->addArgument($container->getParameter('nelmio_api_doc.use_validation_groups')) ->addArgument($container->getParameter('form.type_extension.csrf.enabled')) diff --git a/src/DependencyInjection/NelmioApiDocExtension.php b/src/DependencyInjection/NelmioApiDocExtension.php index c05d411ef..557b25930 100644 --- a/src/DependencyInjection/NelmioApiDocExtension.php +++ b/src/DependencyInjection/NelmioApiDocExtension.php @@ -164,7 +164,7 @@ public function load(array $configs, ContainerBuilder $container): void )); $container->getDefinition('nelmio_api_doc.model_describers.object') - ->setArgument(3, $config['media_types']); + ->setArgument(2, $config['media_types']); // Add autoconfiguration for model describer $container->registerForAutoconfiguration(ModelDescriberInterface::class) @@ -246,7 +246,6 @@ public function load(array $configs, ContainerBuilder $container): void ->setPublic(false) ->setArguments([ new Reference('jms_serializer.metadata_factory'), - new Reference('annotations.reader', ContainerInterface::NULL_ON_INVALID_REFERENCE), $config['media_types'], $jmsNamingStrategy, $container->getParameter('nelmio_api_doc.use_validation_groups'), diff --git a/src/ModelDescriber/FormModelDescriber.php b/src/ModelDescriber/FormModelDescriber.php index a277329eb..bd6e7f5a3 100644 --- a/src/ModelDescriber/FormModelDescriber.php +++ b/src/ModelDescriber/FormModelDescriber.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\ModelDescriber; -use Doctrine\Common\Annotations\Reader; use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface; use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait; use Nelmio\ApiDocBundle\Model\Model; @@ -39,7 +38,6 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry use SetsContextTrait; private ?FormFactoryInterface $formFactory; - private ?Reader $doctrineReader; /** * @var string[] @@ -53,13 +51,11 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry */ public function __construct( ?FormFactoryInterface $formFactory = null, - ?Reader $reader = null, ?array $mediaTypes = null, bool $useValidationGroups = false, bool $isFormCsrfExtensionEnabled = false ) { $this->formFactory = $formFactory; - $this->doctrineReader = $reader; if (null === $mediaTypes) { $mediaTypes = ['json']; diff --git a/src/ModelDescriber/JMSModelDescriber.php b/src/ModelDescriber/JMSModelDescriber.php index 79d846dc3..f5497efa7 100644 --- a/src/ModelDescriber/JMSModelDescriber.php +++ b/src/ModelDescriber/JMSModelDescriber.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\ModelDescriber; -use Doctrine\Common\Annotations\Reader; use JMS\Serializer\Context; use JMS\Serializer\ContextFactory\SerializationContextFactoryInterface; use JMS\Serializer\Exclusion\GroupsExclusionStrategy; @@ -42,8 +41,6 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn private ?PropertyNamingStrategyInterface $namingStrategy; - private ?Reader $doctrineReader; - /** * @var array */ @@ -71,7 +68,6 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn */ public function __construct( MetadataFactoryInterface $factory, - ?Reader $reader, array $mediaTypes, ?PropertyNamingStrategyInterface $namingStrategy = null, bool $useValidationGroups = false, @@ -79,7 +75,6 @@ public function __construct( ) { $this->factory = $factory; $this->namingStrategy = $namingStrategy; - $this->doctrineReader = $reader; $this->mediaTypes = $mediaTypes; $this->useValidationGroups = $useValidationGroups; $this->contextFactory = $contextFactory; diff --git a/src/ModelDescriber/ObjectModelDescriber.php b/src/ModelDescriber/ObjectModelDescriber.php index 89a3cc1d2..0ff4effdd 100644 --- a/src/ModelDescriber/ObjectModelDescriber.php +++ b/src/ModelDescriber/ObjectModelDescriber.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\ModelDescriber; -use Doctrine\Common\Annotations\Reader; use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface; use Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait; use Nelmio\ApiDocBundle\Model\Model; @@ -33,7 +32,6 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar private PropertyInfoExtractorInterface $propertyInfo; private ?ClassMetadataFactoryInterface $classMetadataFactory; - private ?Reader $doctrineReader; /** @var PropertyDescriberInterface|PropertyDescriberInterface[] */ private $propertyDescriber; /** @var string[] */ @@ -49,7 +47,6 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar */ public function __construct( PropertyInfoExtractorInterface $propertyInfo, - ?Reader $reader, $propertyDescribers, array $mediaTypes, ?NameConverterInterface $nameConverter = null, @@ -65,7 +62,6 @@ public function __construct( } $this->propertyInfo = $propertyInfo; - $this->doctrineReader = $reader; $this->propertyDescriber = $propertyDescribers; $this->mediaTypes = $mediaTypes; $this->nameConverter = $nameConverter; diff --git a/tests/Functional/FunctionalTest.php b/tests/Functional/FunctionalTest.php index 0dc6a510b..02bbfccee 100644 --- a/tests/Functional/FunctionalTest.php +++ b/tests/Functional/FunctionalTest.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\Functional; -use Doctrine\Common\Annotations\Reader; use Nelmio\ApiDocBundle\OpenApiPhp\Util; use OpenApi\Annotations as OAAnnotations; use OpenApi\Attributes as OAAttributes; @@ -62,9 +61,7 @@ public function testFetchArticleAction(string $articleRoute): void public static function provideArticleRoute(): \Generator { - if (interface_exists(Reader::class)) { - yield 'Annotations' => ['/api/article/{id}']; - } + yield 'Annotations' => ['/api/article/{id}']; yield 'Attributes' => ['/api/article_attributes/{id}']; } diff --git a/tests/ModelDescriber/FormModelDescriberTest.php b/tests/ModelDescriber/FormModelDescriberTest.php index ede497e0b..992c98d0e 100644 --- a/tests/ModelDescriber/FormModelDescriberTest.php +++ b/tests/ModelDescriber/FormModelDescriberTest.php @@ -11,7 +11,6 @@ namespace Nelmio\ApiDocBundle\Tests\ModelDescriber; -use Doctrine\Common\Annotations\Reader; use Nelmio\ApiDocBundle\Model\Model; use Nelmio\ApiDocBundle\Model\ModelRegistry; use Nelmio\ApiDocBundle\ModelDescriber\FormModelDescriber; @@ -56,14 +55,12 @@ public function testDescribeCreatesTokenPropertyDependingOnOptions(bool $csrfPro ->method('create') ->willReturn($formMock); - $annotationReader = $this->createMock(Reader::class); - $api = new OpenApi(); $model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, FormType::class)); $schema = $this->initSchema(); $modelRegistry = new ModelRegistry([], $api); - $describer = new FormModelDescriber($formFactoryMock, $annotationReader, [], false, true); + $describer = new FormModelDescriber($formFactoryMock, [], false, true); $describer->setModelRegistry($modelRegistry); $describer->describe($model, $schema);