diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fa573d7b98..438b1229c84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -65,8 +65,6 @@ jobs: path: ${{ steps.composercache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} restore-keys: ${{ runner.os }}-composer- - - name: Allow unstable project dependencies - run: composer config minimum-stability dev - name: Update project dependencies run: composer update --no-interaction --no-progress --ansi - name: Require Symfony components diff --git a/src/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommand.php b/src/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommand.php index d5636e29204..dc65594ad0b 100644 --- a/src/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommand.php +++ b/src/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommand.php @@ -46,14 +46,14 @@ final class UpgradeApiResourceCommand extends Command private $identifiersExtractor; private $localCache = []; - public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, SubresourceOperationFactoryInterface $subresourceOperationFactory, SubresourceTransformer $subresourceTransformer, AnnotationReader $reader, IdentifiersExtractorInterface $identifiersExtractor) + public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, SubresourceOperationFactoryInterface $subresourceOperationFactory, SubresourceTransformer $subresourceTransformer, IdentifiersExtractorInterface $identifiersExtractor, AnnotationReader $reader = null) { $this->resourceNameCollectionFactory = $resourceNameCollectionFactory; $this->resourceMetadataFactory = $resourceMetadataFactory; $this->subresourceOperationFactory = $subresourceOperationFactory; $this->subresourceTransformer = $subresourceTransformer; - $this->reader = $reader; $this->identifiersExtractor = $identifiersExtractor; + $this->reader = $reader; parent::__construct(); } @@ -248,6 +248,10 @@ private function readApiResource(string $resourceClass): array return [$attributes[0]->newInstance(), false]; } + if (null === $this->reader) { + throw new \RuntimeException(sprintf('Resource "%s" not found.', $resourceClass)); + } + return [$this->reader->getClassAnnotation($reflectionClass, ApiResource::class), true]; } } diff --git a/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml b/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml index a44d410c108..33f0b6094fb 100644 --- a/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml +++ b/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml @@ -12,8 +12,8 @@ - + diff --git a/tests/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommandTest.php b/tests/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommandTest.php index bc1b88225bc..a67f0904c4b 100644 --- a/tests/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommandTest.php +++ b/tests/Core/Bridge/Symfony/Bundle/Command/UpgradeApiResourceCommandTest.php @@ -40,7 +40,7 @@ private function getCommandTester(ResourceNameCollectionFactoryInterface $resour $application->setCatchExceptions(false); $application->setAutoExit(false); - $application->add(new UpgradeApiResourceCommand($resourceNameCollectionFactory, $resourceMetadataFactory, $subresourceOperationFactory, new SubresourceTransformer(), new AnnotationReader(), $identifiersExtractor->reveal())); + $application->add(new UpgradeApiResourceCommand($resourceNameCollectionFactory, $resourceMetadataFactory, $subresourceOperationFactory, new SubresourceTransformer(), $identifiersExtractor->reveal(), new AnnotationReader())); $command = $application->find('api:upgrade-resource');