From e52b2f3ce4f587db6fb958f1c556a8f1ca5efc34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 20 Dec 2023 17:58:15 +0100 Subject: [PATCH 01/11] chore: remove comparator conflict in 3.2 (#6063) Same commit than cbc803cab81bc6acbe74c4db4eba63bc8539aa16 for 3.2 branch --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 8da70279d83..55ae07ef981 100644 --- a/composer.json +++ b/composer.json @@ -107,7 +107,6 @@ "doctrine/mongodb-odm": "<2.4", "doctrine/persistence": "<1.3", "symfony/var-exporter": "<6.1.1", - "sebastian/comparator": ">=5.0", "phpunit/phpunit": "<9.5", "phpspec/prophecy": "<1.15", "elasticsearch/elasticsearch": ">=8.0,<8.4" From fe07a7f8196bfbefd2f8d02d0f7cacb6b1fbf527 Mon Sep 17 00:00:00 2001 From: soyuka Date: Wed, 20 Dec 2023 18:01:35 +0100 Subject: [PATCH 02/11] chore: changelog 3.2.9 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a33cf391ffc..62ff4f6c4ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v3.2.9 + +* [ecffcde](https://github.com/api-platform/core/pull/6063/commits/ecffcdeb0a27e49256c56502f6f6e327d9e03d5b) chore: remove comparator conflict wrongly introduced + ## v3.2.8 ### Bug fixes From 5de077e7de94f2e07ca615efc5ecf1b32b37a10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Nork=C5=ABnas?= Date: Sat, 23 Dec 2023 10:15:42 +0200 Subject: [PATCH 03/11] fix(symfony): use Type constraint violation code instead of exception code (#6064) --- features/main/validation.feature | 14 +++++++------- src/Symfony/EventListener/DeserializeListener.php | 2 +- .../EventListener/DeserializeListenerTest.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/features/main/validation.feature b/features/main/validation.feature index 0ed47344dcb..570976f4d65 100644 --- a/features/main/validation.feature +++ b/features/main/validation.feature @@ -102,39 +102,39 @@ Feature: Using validations groups { "propertyPath": "", "message": "This value should be of type unknown.", - "code": "0", + "code": "ba785a8c-82cb-4283-967c-3cf342181b40", "hint": "Failed to create object because the class misses the \"baz\" property." }, { "propertyPath": "qux", "message": "This value should be of type string.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "foo", "message": "This value should be of type bool.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "bar", "message": "This value should be of type int.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "uuid", "message": "This value should be of type uuid.", - "code": "0", + "code": "ba785a8c-82cb-4283-967c-3cf342181b40", "hint": "Invalid UUID string: y" }, { "propertyPath": "relatedDummy", "message": "This value should be of type array|string.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "relatedDummies", "message": "This value should be of type array.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" } ] } diff --git a/src/Symfony/EventListener/DeserializeListener.php b/src/Symfony/EventListener/DeserializeListener.php index a56f8475bcf..9f147522ed0 100644 --- a/src/Symfony/EventListener/DeserializeListener.php +++ b/src/Symfony/EventListener/DeserializeListener.php @@ -111,7 +111,7 @@ public function onKernelRequest(RequestEvent $event): void if ($exception->canUseMessageForUser()) { $parameters['hint'] = $exception->getMessage(); } - $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) $exception->getCode())); + $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, Type::INVALID_TYPE_ERROR)); } if (0 !== \count($violations)) { throw new ValidationException($violations); diff --git a/tests/Symfony/EventListener/DeserializeListenerTest.php b/tests/Symfony/EventListener/DeserializeListenerTest.php index 197dfa1c22d..8290d47b801 100644 --- a/tests/Symfony/EventListener/DeserializeListenerTest.php +++ b/tests/Symfony/EventListener/DeserializeListenerTest.php @@ -366,7 +366,7 @@ public function testTurnPartialDenormalizationExceptionIntoValidationException() $this->assertSame($violation->getPropertyPath(), 'foo'); $this->assertNull($violation->getInvalidValue()); $this->assertNull($violation->getPlural()); - $this->assertSame($violation->getCode(), '0'); + $this->assertSame($violation->getCode(), 'ba785a8c-82cb-4283-967c-3cf342181b40'); } } } From f75649d49139e332bb739aece56a315943162770 Mon Sep 17 00:00:00 2001 From: soyuka Date: Sat, 23 Dec 2023 09:31:52 +0100 Subject: [PATCH 04/11] fix(symfony): use Type constraint violation code instead of exception code --- features/main/validation.feature | 14 +++++++------- src/State/Provider/DeserializeProvider.php | 2 +- src/Symfony/EventListener/DeserializeListener.php | 2 +- .../EventListener/DeserializeListenerTest.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/features/main/validation.feature b/features/main/validation.feature index 170c4c51a27..b8ab1feb8a6 100644 --- a/features/main/validation.feature +++ b/features/main/validation.feature @@ -119,40 +119,40 @@ Feature: Using validations groups { "propertyPath": "", "message": "This value should be of type unknown.", - "code": "0", + "code": "ba785a8c-82cb-4283-967c-3cf342181b40", "hint": "Failed to create object because the class misses the \"baz\" property." }, { "propertyPath": "qux", "message": "This value should be of type string.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "foo", "message": "This value should be of type bool.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "bar", "message": "This value should be of type int.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" }, { "propertyPath": "uuid", "message": "This value should be of type uuid.", - "code": "0", + "code": "ba785a8c-82cb-4283-967c-3cf342181b40", "hint": "Invalid UUID string: y" }, { "propertyPath": "relatedDummy", "message": "This value should be of type array|string.", - "code": "0", + "code": "ba785a8c-82cb-4283-967c-3cf342181b40", "hint": "The type of the \"relatedDummy\" attribute must be \"array\" (nested document) or \"string\" (IRI), \"integer\" given." }, { "propertyPath": "relatedDummies", "message": "This value should be of type array.", - "code": "0" + "code": "ba785a8c-82cb-4283-967c-3cf342181b40" } ] } diff --git a/src/State/Provider/DeserializeProvider.php b/src/State/Provider/DeserializeProvider.php index 0bebb6b234e..b2217275051 100644 --- a/src/State/Provider/DeserializeProvider.php +++ b/src/State/Provider/DeserializeProvider.php @@ -97,7 +97,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c if ($exception->canUseMessageForUser()) { $parameters['hint'] = $exception->getMessage(); } - $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) $exception->getCode())); + $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) Type::INVALID_TYPE_ERROR)); } if (0 !== \count($violations)) { throw new ValidationException($violations); diff --git a/src/Symfony/EventListener/DeserializeListener.php b/src/Symfony/EventListener/DeserializeListener.php index e4349f899d0..a246ad9fef3 100644 --- a/src/Symfony/EventListener/DeserializeListener.php +++ b/src/Symfony/EventListener/DeserializeListener.php @@ -115,7 +115,7 @@ public function onKernelRequest(RequestEvent $event): void if ($exception->canUseMessageForUser()) { $parameters['hint'] = $exception->getMessage(); } - $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, (string) $exception->getCode())); + $violations->add(new ConstraintViolation($this->translator->trans($message, ['{{ type }}' => implode('|', $exception->getExpectedTypes() ?? [])], 'validators'), $message, $parameters, null, $exception->getPath(), null, null, Type::INVALID_TYPE_ERROR)); } if (0 !== \count($violations)) { throw new ValidationException($violations); diff --git a/tests/Symfony/EventListener/DeserializeListenerTest.php b/tests/Symfony/EventListener/DeserializeListenerTest.php index 197dfa1c22d..8290d47b801 100644 --- a/tests/Symfony/EventListener/DeserializeListenerTest.php +++ b/tests/Symfony/EventListener/DeserializeListenerTest.php @@ -366,7 +366,7 @@ public function testTurnPartialDenormalizationExceptionIntoValidationException() $this->assertSame($violation->getPropertyPath(), 'foo'); $this->assertNull($violation->getInvalidValue()); $this->assertNull($violation->getPlural()); - $this->assertSame($violation->getCode(), '0'); + $this->assertSame($violation->getCode(), 'ba785a8c-82cb-4283-967c-3cf342181b40'); } } } From dc77c7949a6e8c48d57708d8f43027e00124388c Mon Sep 17 00:00:00 2001 From: soyuka Date: Sat, 23 Dec 2023 09:33:13 +0100 Subject: [PATCH 05/11] fix(symfony): disable symfony error handling by default --- .../DependencyInjection/ApiPlatformExtension.php | 1 + .../Bundle/DependencyInjection/Configuration.php | 1 + .../Bundle/Resources/config/symfony/events.xml | 1 + src/Symfony/EventListener/ExceptionListener.php | 12 +++++++++++- tests/Fixtures/app/config/config_common.yml | 1 + 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index 4c4b3658d32..134fe401aba 100644 --- a/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -232,6 +232,7 @@ private function registerCommonConfiguration(ContainerBuilder $container, array $container->setParameter('api_platform.collection.pagination.items_per_page_parameter_name', $config['defaults']['pagination_items_per_page_parameter_name'] ?? $config['collection']['pagination']['items_per_page_parameter_name']); $container->setParameter('api_platform.collection.pagination.partial_parameter_name', $config['defaults']['pagination_partial_parameter_name'] ?? $config['collection']['pagination']['partial_parameter_name']); $container->setParameter('api_platform.collection.pagination', $this->getPaginationDefaults($config['defaults'] ?? [], $config['collection']['pagination'])); + $container->setParameter('api_platform.handle_symfony_errors', $config['handle_symfony_errors'] ?? false); $container->setParameter('api_platform.http_cache.etag', $config['defaults']['cache_headers']['etag'] ?? true); $container->setParameter('api_platform.http_cache.max_age', $config['defaults']['cache_headers']['max_age'] ?? null); $container->setParameter('api_platform.http_cache.shared_max_age', $config['defaults']['cache_headers']['shared_max_age'] ?? null); diff --git a/src/Symfony/Bundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/DependencyInjection/Configuration.php index aa40e22253d..948cf49f156 100644 --- a/src/Symfony/Bundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/DependencyInjection/Configuration.php @@ -103,6 +103,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->booleanNode('force_eager')->defaultTrue()->info('Force join on every relation. If disabled, it will only join relations having the EAGER fetch mode.')->end() ->end() ->end() + ->booleanNode('handle_symfony_errors')->defaultFalse()->info('Allows to handle symfony exceptions.')->end() ->booleanNode('enable_swagger')->defaultTrue()->info('Enable the Swagger documentation and export.')->end() ->booleanNode('enable_swagger_ui')->defaultValue(class_exists(TwigBundle::class))->info('Enable Swagger UI')->end() ->booleanNode('enable_re_doc')->defaultValue(class_exists(TwigBundle::class))->info('Enable ReDoc')->end() diff --git a/src/Symfony/Bundle/Resources/config/symfony/events.xml b/src/Symfony/Bundle/Resources/config/symfony/events.xml index 41b8d29ac02..f16daef8574 100644 --- a/src/Symfony/Bundle/Resources/config/symfony/events.xml +++ b/src/Symfony/Bundle/Resources/config/symfony/events.xml @@ -6,6 +6,7 @@ + %api_platform.handle_symfony_errors% diff --git a/src/Symfony/EventListener/ExceptionListener.php b/src/Symfony/EventListener/ExceptionListener.php index bb59aa04621..e3b5b0730b3 100644 --- a/src/Symfony/EventListener/ExceptionListener.php +++ b/src/Symfony/EventListener/ExceptionListener.php @@ -14,6 +14,7 @@ namespace ApiPlatform\Symfony\EventListener; use ApiPlatform\Metadata\Error; +use ApiPlatform\Util\RequestAttributesExtractor; use Symfony\Component\HttpKernel\Event\ExceptionEvent; use Symfony\Component\HttpKernel\EventListener\ErrorListener; @@ -25,13 +26,22 @@ */ final class ExceptionListener { - public function __construct(private readonly ErrorListener $errorListener) + public function __construct(private readonly ErrorListener $errorListener, public bool $handleSymfonyErrors = false) { } public function onKernelException(ExceptionEvent $event): void { $request = $event->getRequest(); + + // Normalize exceptions only for routes managed by API Platform + if ( + false === $this->handleSymfonyErrors && + !((RequestAttributesExtractor::extractAttributes($request)['respond'] ?? $request->attributes->getBoolean('_api_respond', false)) || $request->attributes->getBoolean('_graphql', false)) + ) { + return; + } + // Don't loop on errors leave it to Symfony as we could not handle this properly if (($operation = $request->attributes->get('_api_operation')) && $operation instanceof Error) { return; diff --git a/tests/Fixtures/app/config/config_common.yml b/tests/Fixtures/app/config/config_common.yml index f75fd7ef873..2eeeddbfaa3 100644 --- a/tests/Fixtures/app/config/config_common.yml +++ b/tests/Fixtures/app/config/config_common.yml @@ -73,6 +73,7 @@ api_platform: Symfony\Component\Serializer\Exception\ExceptionInterface: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST ApiPlatform\Exception\InvalidArgumentException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST ApiPlatform\Exception\FilterValidationException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST + handle_symfony_errors: true http_cache: invalidation: enabled: true From 6f3c6a663cc55730580b82d146b8d62cac4f1bc5 Mon Sep 17 00:00:00 2001 From: de Roland Date: Sat, 23 Dec 2023 09:34:52 +0100 Subject: [PATCH 06/11] fix(symfony): attribute filter names (#6062) * fix: Use ApiPlatform\Metadata\Util tools instead of deprecated ApiPlatform\Util ones (Issue #6023) * fix: Use ApiPlatform\Metadata\Util tools instead of deprecated ApiPlatform\Util ones (Issue #6023) => update docs * csfix --- docs/src/DependencyInjection/Compiler/AttributeFilterPass.php | 2 +- .../Bundle/DependencyInjection/Compiler/AttributeFilterPass.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php b/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php index a6bf1432e3d..a38b1efcd55 100644 --- a/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php +++ b/docs/src/DependencyInjection/Compiler/AttributeFilterPass.php @@ -13,7 +13,7 @@ namespace ApiPlatform\Playground\DependencyInjection\Compiler; -use ApiPlatform\Util\AttributeFilterExtractorTrait; +use ApiPlatform\Metadata\Util\AttributeFilterExtractorTrait; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php b/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php index 14af328e000..ed9b98c4c45 100644 --- a/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php +++ b/src/Symfony/Bundle/DependencyInjection/Compiler/AttributeFilterPass.php @@ -14,8 +14,8 @@ namespace ApiPlatform\Symfony\Bundle\DependencyInjection\Compiler; use ApiPlatform\Metadata\ApiFilter; +use ApiPlatform\Metadata\Util\AttributeFilterExtractorTrait; use ApiPlatform\Metadata\Util\ReflectionClassRecursiveIterator; -use ApiPlatform\Util\AttributeFilterExtractorTrait; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; From 4f1b08cfff1bfff8f43a66e690a671efd7c7a59a Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Thu, 21 Dec 2023 13:52:47 +0100 Subject: [PATCH 07/11] Update SearchFilterInterface.php --- src/Doctrine/Common/Filter/SearchFilterInterface.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Doctrine/Common/Filter/SearchFilterInterface.php b/src/Doctrine/Common/Filter/SearchFilterInterface.php index 198129dc4f5..177289b4734 100644 --- a/src/Doctrine/Common/Filter/SearchFilterInterface.php +++ b/src/Doctrine/Common/Filter/SearchFilterInterface.php @@ -39,7 +39,7 @@ interface SearchFilterInterface /** * @var string The value must be contained in the field case-insensitive */ - public const STRATEGY_IPARTIAL = 'partial'; + public const STRATEGY_IPARTIAL = 'ipartial'; /** * @var string Finds fields that are starting with the value @@ -49,7 +49,7 @@ interface SearchFilterInterface /** * @var string Finds fields that are starting with the value case-insensitive */ - public const STRATEGY_ISTART = 'start'; + public const STRATEGY_ISTART = 'istart'; /** * @var string Finds fields that are ending with the value @@ -59,7 +59,7 @@ interface SearchFilterInterface /** * @var string Finds fields that are ending with the value case-insensitive */ - public const STRATEGY_IEND = 'end'; + public const STRATEGY_IEND = 'iend'; /** * @var string Finds fields that are starting with the word @@ -69,5 +69,5 @@ interface SearchFilterInterface /** * @var string Finds fields that are starting with the word case-insensitive */ - public const STRATEGY_IWORD_START = 'word_start'; + public const STRATEGY_IWORD_START = 'iword_start'; } From 05629a1229f705d1abf927d130ffd70b5dfe86bd Mon Sep 17 00:00:00 2001 From: soyuka Date: Sat, 23 Dec 2023 09:37:05 +0100 Subject: [PATCH 08/11] chore: changelog 3.2.10 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62ff4f6c4ef..a8a71712b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## v3.2.10 + +### Bug fixes + +* [6f3c6a663](https://github.com/api-platform/core/commit/6f3c6a663cc55730580b82d146b8d62cac4f1bc5) fix(symfony): attribute filter names (#6062) +* [dc77c7949](https://github.com/api-platform/core/commit/dc77c7949a6e8c48d57708d8f43027e00124388c) fix(symfony): disable symfony error handling by default +* [f75649d49](https://github.com/api-platform/core/commit/f75649d49139e332bb739aece56a315943162770) fix(symfony): use Type constraint violation code instead of exception code + ## v3.2.9 * [ecffcde](https://github.com/api-platform/core/pull/6063/commits/ecffcdeb0a27e49256c56502f6f6e327d9e03d5b) chore: remove comparator conflict wrongly introduced @@ -1981,4 +1989,4 @@ Please read #2825 if you have issues with the behavior of Readable/Writable Link ## 1.0.0 beta 2 * Preserve indexes when normalizing and denormalizing associative arrays -* Allow setting default order for property when registering a `Doctrine\Orm\Filter\OrderFilter` instance +* Allow setting default order for property when registering a `Doctrine\Orm\Filter\OrderFilter` instance \ No newline at end of file From 66ae7a2ca5efc4a9f387561d7e10abb59dbdbb59 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 29 Dec 2023 10:45:10 +0100 Subject: [PATCH 09/11] test(symfony): disable symfony error handling by default --- tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php index 2cadbb0d603..33eda6cf678 100644 --- a/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php +++ b/tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php @@ -226,6 +226,7 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm ], 'keep_legacy_inflector' => true, 'event_listeners_backward_compatibility_layer' => true, + 'handle_symfony_errors' => false, ], $config); } From 36850102ac750797f1acabe0c753d17f233a87c6 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 29 Dec 2023 17:24:25 +0100 Subject: [PATCH 10/11] style: latest cs-fixer --- src/JsonApi/Serializer/ConstraintViolationListNormalizer.php | 2 +- .../NotExposedOperationResourceMetadataCollectionFactory.php | 2 +- tests/Behat/DoctrineContext.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php index 148119dd57c..90c87a881cf 100644 --- a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php +++ b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php @@ -22,7 +22,7 @@ use Symfony\Component\Validator\ConstraintViolationListInterface; /** - * Converts {@see \Symfony\Component\Validator\ConstraintViolationListInterface} to a JSON API error representation. + * Converts {@see ConstraintViolationListInterface} to a JSON API error representation. * * @author Héctor Hurtarte */ diff --git a/src/Metadata/Resource/Factory/NotExposedOperationResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/NotExposedOperationResourceMetadataCollectionFactory.php index bf3afc2bec9..cf70ce228e4 100644 --- a/src/Metadata/Resource/Factory/NotExposedOperationResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/NotExposedOperationResourceMetadataCollectionFactory.php @@ -60,7 +60,7 @@ public function create(string $resourceClass): ResourceMetadataCollection foreach ($resourceMetadataCollection as $resource) { $operations = $resource->getOperations(); - /** @var \ApiPlatform\Metadata\HttpOperation $operation */ + /** @var HttpOperation $operation */ foreach ($operations as $operation) { // An item operation has been found, nothing to do anymore in this factory if ((HttpOperation::METHOD_GET === $operation->getMethod() && !$operation instanceof CollectionOperationInterface) || ($operation->getExtraProperties()['is_legacy_resource_metadata'] ?? false)) { diff --git a/tests/Behat/DoctrineContext.php b/tests/Behat/DoctrineContext.php index 17cc076c3e7..8b5db33a3b6 100644 --- a/tests/Behat/DoctrineContext.php +++ b/tests/Behat/DoctrineContext.php @@ -2168,7 +2168,7 @@ public function thereIsADummyWithSubEntity(string $strId, string $name): void public function thereIsAGroupWithUuidAndNUsers(string $uuid, int $nbUsers): void { $group = new Group(); - $group->setUuid(\Symfony\Component\Uid\Uuid::fromString($uuid)); + $group->setUuid(SymfonyUuid::fromString($uuid)); $this->manager->persist($group); From 568798688721275f0b705d638924fb7b070d018b Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 29 Dec 2023 17:31:44 +0100 Subject: [PATCH 11/11] style: latest cs-fixer --- src/Doctrine/Odm/State/LinksHandlerInterface.php | 2 +- src/Doctrine/Odm/State/Options.php | 2 +- src/Doctrine/Orm/State/LinksHandlerInterface.php | 2 +- src/Doctrine/Orm/State/Options.php | 2 +- src/Elasticsearch/Tests/State/ItemProviderTest.php | 2 +- src/Metadata/Util/ContentNegotiationTrait.php | 2 +- src/Symfony/EventListener/ExceptionListener.php | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Doctrine/Odm/State/LinksHandlerInterface.php b/src/Doctrine/Odm/State/LinksHandlerInterface.php index 9d2835b0e2e..a60421fe1f9 100644 --- a/src/Doctrine/Odm/State/LinksHandlerInterface.php +++ b/src/Doctrine/Odm/State/LinksHandlerInterface.php @@ -24,7 +24,7 @@ interface LinksHandlerInterface /** * Handle Doctrine ORM links. * - * @see ApiPlatform\Doctrine\Odm\State\LinksHandlerTrait + * @see LinksHandlerTrait * * @param array $uriVariables * @param array{entityClass: string, operation: Operation}&array $context diff --git a/src/Doctrine/Odm/State/Options.php b/src/Doctrine/Odm/State/Options.php index edc56dceb4b..919c10f8045 100644 --- a/src/Doctrine/Odm/State/Options.php +++ b/src/Doctrine/Odm/State/Options.php @@ -20,7 +20,7 @@ class Options implements OptionsInterface /** * @param mixed $handleLinks experimental callable, typed mixed as we may want a service name in the future * - * @see \ApiPlatform\Doctrine\Odm\State\LinksHandlerInterface + * @see LinksHandlerInterface */ public function __construct( protected ?string $documentClass = null, diff --git a/src/Doctrine/Orm/State/LinksHandlerInterface.php b/src/Doctrine/Orm/State/LinksHandlerInterface.php index be78bc06bd7..98b75c078ef 100644 --- a/src/Doctrine/Orm/State/LinksHandlerInterface.php +++ b/src/Doctrine/Orm/State/LinksHandlerInterface.php @@ -25,7 +25,7 @@ interface LinksHandlerInterface /** * Handle Doctrine ORM links. * - * @see ApiPlatform\Doctrine\Orm\State\LinksHandlerTrait + * @see LinksHandlerTrait * * @param array $uriVariables * @param array{entityClass: string, operation: Operation}&array $context diff --git a/src/Doctrine/Orm/State/Options.php b/src/Doctrine/Orm/State/Options.php index e5704a253c0..50d13f1b7a4 100644 --- a/src/Doctrine/Orm/State/Options.php +++ b/src/Doctrine/Orm/State/Options.php @@ -20,7 +20,7 @@ class Options implements OptionsInterface /** * @param string|callable $handleLinks experimental callable, typed mixed as we may want a service name in the future * - * @see \ApiPlatform\Doctrine\Orm\State\LinksHandlerInterface + * @see LinksHandlerInterface */ public function __construct( protected ?string $entityClass = null, diff --git a/src/Elasticsearch/Tests/State/ItemProviderTest.php b/src/Elasticsearch/Tests/State/ItemProviderTest.php index 64fe245d8bd..0a260acef4b 100644 --- a/src/Elasticsearch/Tests/State/ItemProviderTest.php +++ b/src/Elasticsearch/Tests/State/ItemProviderTest.php @@ -91,7 +91,7 @@ public function testGetInexistantItem(): void $documentMetadataFactoryProphecy = $this->prophesize(DocumentMetadataFactoryInterface::class); - $clientClass = class_exists(\Elasticsearch\Client::class) ? \Elasticsearch\Client::class : \Elastic\Elasticsearch\ClientInterface::class; + $clientClass = class_exists(\Elasticsearch\Client::class) ? \Elasticsearch\Client::class : ClientInterface::class; $clientProphecy = $this->prophesize($clientClass); $clientProphecy->get(['index' => 'foo', 'id' => '404'])->willReturn([ diff --git a/src/Metadata/Util/ContentNegotiationTrait.php b/src/Metadata/Util/ContentNegotiationTrait.php index 4a257d81fcb..c86b2cc3c28 100644 --- a/src/Metadata/Util/ContentNegotiationTrait.php +++ b/src/Metadata/Util/ContentNegotiationTrait.php @@ -28,7 +28,7 @@ trait ContentNegotiationTrait /** * Gets the format associated with the mime type. * - * Adapted from {@see \Symfony\Component\HttpFoundation\Request::getFormat}. + * Adapted from {@see Request::getFormat}. * * @param array $formats */ diff --git a/src/Symfony/EventListener/ExceptionListener.php b/src/Symfony/EventListener/ExceptionListener.php index e3b5b0730b3..7aa50a5a995 100644 --- a/src/Symfony/EventListener/ExceptionListener.php +++ b/src/Symfony/EventListener/ExceptionListener.php @@ -36,8 +36,8 @@ public function onKernelException(ExceptionEvent $event): void // Normalize exceptions only for routes managed by API Platform if ( - false === $this->handleSymfonyErrors && - !((RequestAttributesExtractor::extractAttributes($request)['respond'] ?? $request->attributes->getBoolean('_api_respond', false)) || $request->attributes->getBoolean('_graphql', false)) + false === $this->handleSymfonyErrors + && !((RequestAttributesExtractor::extractAttributes($request)['respond'] ?? $request->attributes->getBoolean('_api_respond', false)) || $request->attributes->getBoolean('_graphql', false)) ) { return; }