From 4693cf496ae944af87ce4cbf67f0c54d83ac8867 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 29 Apr 2022 15:30:29 +0200 Subject: [PATCH 1/5] fix(symfony): optional doctrine/annotation for upgrade command --- .../Symfony/Bundle/Command/UpgradeApiResourceCommand.php | 8 ++++++-- src/Symfony/Bundle/Resources/config/legacy/upgrade.xml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) 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..3c869f241f1 100644 --- a/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml +++ b/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml @@ -12,7 +12,7 @@ - + From 452e215150b95dbd9be1fcace0e31f0ad8bef788 Mon Sep 17 00:00:00 2001 From: soyuka Date: Mon, 2 May 2022 17:09:06 +0200 Subject: [PATCH 2/5] fix phpstan? --- .../Symfony/Bundle/Command/UpgradeApiResourceCommandTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'); From cc68248e5a27290893dcecc2e8c4e5127d2a79ca Mon Sep 17 00:00:00 2001 From: soyuka Date: Mon, 2 May 2022 17:41:52 +0200 Subject: [PATCH 3/5] do not use phpstan dev --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fa573d7b98..77c2344c50c 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 @@ -91,6 +89,7 @@ jobs: SYMFONY_PHPUNIT_VERSION: '9.5' run: | ./vendor/bin/phpstan --version + # rm src/Core/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetLegacy.php ./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi phpunit: From 90582b6852582c6782791f4ac9d797560a3e319f Mon Sep 17 00:00:00 2001 From: soyuka Date: Mon, 2 May 2022 17:42:53 +0200 Subject: [PATCH 4/5] do not use phpstan dev --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77c2344c50c..438b1229c84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,6 @@ jobs: SYMFONY_PHPUNIT_VERSION: '9.5' run: | ./vendor/bin/phpstan --version - # rm src/Core/Bridge/Symfony/Bundle/Test/Constraint/ArraySubsetLegacy.php ./vendor/bin/phpstan analyse --no-interaction --no-progress --ansi phpunit: From 08fed33bd7e32d1e0cbd023d9f8ea8cc44f34a86 Mon Sep 17 00:00:00 2001 From: soyuka Date: Mon, 2 May 2022 17:57:26 +0200 Subject: [PATCH 5/5] oops --- src/Symfony/Bundle/Resources/config/legacy/upgrade.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml b/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml index 3c869f241f1..33f0b6094fb 100644 --- a/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml +++ b/src/Symfony/Bundle/Resources/config/legacy/upgrade.xml @@ -12,8 +12,8 @@ - +