From de389fff7b77c8d256253823b6e2875180039e6f Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Tue, 5 Jun 2018 17:00:06 +0200 Subject: [PATCH 1/2] Move lint jobs to CircleCI --- .circleci/config.yml | 80 ++++++++++++++++++++++++++++++++++++++++---- .php_cs.dist | 27 +++++++++------ .travis.yml | 32 +++--------------- 3 files changed, 96 insertions(+), 43 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 513d7342876..8a6e170d8ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,6 +25,12 @@ reusable-steps: - npm-cache-{{ .Revision }} - npm-cache-{{ .Branch }} - npm-cache + - &restore-php-cs-fixer-cache + restore_cache: + keys: + - php-cs-fixer-cache-{{ .Revision }} + - php-cs-fixer-cache-{{ .Branch }} + - php-cs-fixer-cache - &save-composer-cache-by-branch save_cache: paths: @@ -45,6 +51,16 @@ reusable-steps: paths: - ~/.npm key: npm-cache-{{ .Revision }}-{{ .BuildNum }} + - &save-php-cs-fixer-cache-by-branch + save_cache: + paths: + - .php_cs.cache + key: php-cs-fixer-cache-{{ .Branch }}-{{ .BuildNum }} + - &save-php-cs-fixer-cache-by-revision + save_cache: + paths: + - .php_cs.cache + key: php-cs-fixer-cache-{{ .Revision }}-{{ .BuildNum }} - &update-composer run: name: Update Composer @@ -55,7 +71,55 @@ reusable-steps: command: composer update --prefer-dist --no-progress --no-suggest --ansi jobs: - phpunit-php-7.2-coverage: + php-cs-fixer: + docker: + - image: circleci/php:7.2-node-browsers + environment: + PHP_CS_FIXER_FUTURE_MODE: 1 + working_directory: ~/api-platform/core + steps: + - checkout + - *restore-composer-cache + - *restore-php-cs-fixer-cache + - *disable-xdebug-php-extension + - *disable-php-memory-limit + - *update-composer + - run: + name: Install PHP-CS-Fixer + command: composer global require friendsofphp/php-cs-fixer:^2.12 + - *save-composer-cache-by-revision + - *save-composer-cache-by-branch + - run: + name: Run PHP-CS-Fixer + command: |- + export PATH="$PATH:$HOME/.composer/vendor/bin" + php-cs-fixer fix --dry-run --diff --ansi + - *save-php-cs-fixer-cache-by-revision + - *save-php-cs-fixer-cache-by-branch + + phpstan: + docker: + - image: circleci/php:7.2-node-browsers + working_directory: ~/api-platform/core + steps: + - checkout + - *restore-composer-cache + - *disable-xdebug-php-extension + - *disable-php-memory-limit + - *update-composer + - *update-project-dependencies + - run: + name: Install PHPStan + command: composer global require phpstan/phpstan:^0.8 + - *save-composer-cache-by-revision + - *save-composer-cache-by-branch + - run: + name: Run PHPStan + command: |- + export PATH="$PATH:$HOME/.composer/vendor/bin" + phpstan analyse -c phpstan.neon -l5 --ansi src tests + + phpunit-coverage: docker: - image: circleci/php:7.2-node-browsers environment: @@ -98,7 +162,7 @@ jobs: - *save-npm-cache-by-revision - *save-npm-cache-by-branch - behat-php-7.2-coverage: + behat-coverage: docker: - image: circleci/php:7.2-node-browsers environment: @@ -181,11 +245,15 @@ jobs: workflows: version: 2 + lint: + jobs: + - php-cs-fixer + - phpstan test-with-coverage: jobs: - - phpunit-php-7.2-coverage - - behat-php-7.2-coverage + - phpunit-coverage + - behat-coverage - merge-and-upload-coverage: requires: - - phpunit-php-7.2-coverage - - behat-php-7.2-coverage + - phpunit-coverage + - behat-coverage diff --git a/.php_cs.dist b/.php_cs.dist index 6e8308e2308..bb45efae9ac 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -42,16 +42,23 @@ return PhpCsFixer\Config::create() 'location' => 'after_open', ], 'modernize_types_casting' => true, - 'no_extra_consecutive_blank_lines' => [ - 'break', - 'continue', - 'curly_brace_block', - 'extra', - 'parenthesis_brace_block', - 'return', - 'square_brace_block', - 'throw', - 'use', + 'native_function_invocation' => [ + 'include' => [ + '@compiler_optimized', + ], + ], + 'no_extra_blank_lines' => [ + 'tokens' => [ + 'break', + 'continue', + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'return', + 'square_brace_block', + 'throw', + 'use', + ], ], 'no_useless_else' => true, 'no_useless_return' => true, diff --git a/.travis.yml b/.travis.yml index 876cf5b886f..568cb139241 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ matrix: - php: '7.0' - php: '7.1' - php: '7.2' - - php: '7.2' - env: lint=1 - php: '7.2' env: deps=low - php: '7.2' @@ -40,12 +38,6 @@ matrix: before_install: - phpenv config-rm xdebug.ini || echo "xdebug not available" - echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - if [[ $lint = 1 ]]; then - wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.12.0/php-cs-fixer.phar; - fi - - if [[ $lint = 1 ]]; then - composer global require --dev 'phpstan/phpstan:^0.8'; - fi - export PATH="$PATH:$HOME/.composer/vendor/bin" install: @@ -56,26 +48,12 @@ install: fi script: - - if [[ $lint != 1 ]]; then - tests/Fixtures/app/console cache:clear; - fi - - if [[ $lint != 1 ]]; then - vendor/bin/phpunit; - fi - - if [[ $lint != 1 ]]; then - tests/Fixtures/app/console cache:clear; - fi + - tests/Fixtures/app/console cache:clear + - vendor/bin/phpunit + - tests/Fixtures/app/console cache:clear - if [[ $APP_ENV = 'postgres' ]]; then vendor/bin/behat --suite=postgres --format=progress; - elif [[ $lint != 1 ]]; then + else vendor/bin/behat --suite=default --format=progress; fi - - if [[ $lint != 1 ]]; then - tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json; - fi - - if [[ $lint = 1 ]]; then - php php-cs-fixer.phar fix --dry-run --diff --no-ansi; - fi - - if [[ $lint = 1 ]]; then - phpstan analyse -c phpstan.neon -l5 --ansi src tests; - fi + - tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json From 3ea975594050f49181ce3b9da931409ba8577b40 Mon Sep 17 00:00:00 2001 From: Teoh Han Hui Date: Tue, 5 Jun 2018 18:56:06 +0200 Subject: [PATCH 2/2] Fix files with PHP-CS-Fixer (native_function_invocation) --- features/bootstrap/FeatureContext.php | 16 ++++++++-------- features/bootstrap/HydraContext.php | 4 ++-- features/bootstrap/JsonContext.php | 4 ++-- features/bootstrap/SwaggerContext.php | 2 +- src/Bridge/Doctrine/Common/DataPersister.php | 2 +- src/DataProvider/ChainItemDataProvider.php | 2 +- .../ConstraintViolationListNormalizer.php | 2 +- src/JsonApi/Serializer/ItemNormalizer.php | 6 +++--- .../ReservedAttributeNameConverter.php | 2 +- .../Factory/OperationResourceMetadataFactory.php | 4 ++-- src/Serializer/AbstractCollectionNormalizer.php | 8 ++++---- src/Serializer/SerializerContextBuilder.php | 2 +- src/Util/AnnotationFilterExtractorTrait.php | 4 ++-- .../Orm/Extension/PaginationExtensionTest.php | 2 +- .../ApiPlatformExtensionTest.php | 2 +- .../ChainCollectionDataProviderTest.php | 2 +- .../SerializableResourceDenormalizer.php | 2 +- tests/JsonApi/Serializer/ItemNormalizerTest.php | 2 +- tests/Metadata/Resource/ResourceMetadataTest.php | 4 ++-- 19 files changed, 36 insertions(+), 36 deletions(-) diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 67d14788597..2375594a07d 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -386,9 +386,9 @@ public function thereAreDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string { $descriptions = ['Smart dummy.', 'Not so smart dummy.']; - if (in_array($bool, ['true', '1', 1], true)) { + if (\in_array($bool, ['true', '1', 1], true)) { $bool = true; - } elseif (in_array($bool, ['false', '0', 0], true)) { + } elseif (\in_array($bool, ['false', '0', 0], true)) { $bool = false; } else { $expected = ['true', 'false', '1', '0']; @@ -496,9 +496,9 @@ public function thereAreDummyObjectsWithDummyPrice(int $nb) */ public function thereAreDummyObjectsWithDummyBoolean(int $nb, string $bool) { - if (in_array($bool, ['true', '1', 1], true)) { + if (\in_array($bool, ['true', '1', 1], true)) { $bool = true; - } elseif (in_array($bool, ['false', '0', 0], true)) { + } elseif (\in_array($bool, ['false', '0', 0], true)) { $bool = false; } else { $expected = ['true', 'false', '1', '0']; @@ -524,9 +524,9 @@ public function thereAreDummyObjectsWithDummyBoolean(int $nb, string $bool) */ public function thereAreDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bool) { - if (in_array($bool, ['true', '1', 1], true)) { + if (\in_array($bool, ['true', '1', 1], true)) { $bool = true; - } elseif (in_array($bool, ['false', '0', 0], true)) { + } elseif (\in_array($bool, ['false', '0', 0], true)) { $bool = false; } else { $expected = ['true', 'false', '1', '0']; @@ -551,9 +551,9 @@ public function thereAreDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bo */ public function thereAreDummyObjectsWithRelationEmbeddedDummyBoolean(int $nb, string $bool) { - if (in_array($bool, ['true', '1', 1], true)) { + if (\in_array($bool, ['true', '1', 1], true)) { $bool = true; - } elseif (in_array($bool, ['false', '0', 0], true)) { + } elseif (\in_array($bool, ['false', '0', 0], true)) { $bool = false; } else { $expected = ['true', 'false', '1', '0']; diff --git a/features/bootstrap/HydraContext.php b/features/bootstrap/HydraContext.php index f0f9b765cb5..4bb02f43d75 100644 --- a/features/bootstrap/HydraContext.php +++ b/features/bootstrap/HydraContext.php @@ -118,7 +118,7 @@ public function assertOperationNodeValueContains(string $nodeName, string $opera */ public function assertNbOperationsExist(int $nb, string $className) { - Assert::assertEquals($nb, count($this->getOperations($className))); + Assert::assertEquals($nb, \count($this->getOperations($className))); } /** @@ -126,7 +126,7 @@ public function assertNbOperationsExist(int $nb, string $className) */ public function assertNbPropertiesExist(int $nb, string $className) { - Assert::assertEquals($nb, count($this->getProperties($className))); + Assert::assertEquals($nb, \count($this->getProperties($className))); } /** diff --git a/features/bootstrap/JsonContext.php b/features/bootstrap/JsonContext.php index b56a60523b1..c432860437f 100644 --- a/features/bootstrap/JsonContext.php +++ b/features/bootstrap/JsonContext.php @@ -26,14 +26,14 @@ public function __construct(HttpCallResultPool $httpCallResultPool) private function sortArrays($obj) { - $isObject = is_object($obj); + $isObject = \is_object($obj); foreach ($obj as $key => $value) { if (null === $value || is_scalar($value)) { continue; } - if (is_array($value)) { + if (\is_array($value)) { sort($value); } diff --git a/features/bootstrap/SwaggerContext.php b/features/bootstrap/SwaggerContext.php index 75da107e6dd..643026de458 100644 --- a/features/bootstrap/SwaggerContext.php +++ b/features/bootstrap/SwaggerContext.php @@ -90,7 +90,7 @@ public function assertPropertyExist(string $propertyName, string $className) */ public function assertPropertyIsRequired(string $propertyName, string $className) { - if (!in_array($propertyName, $this->getClassInfo($className)->required, true)) { + if (!\in_array($propertyName, $this->getClassInfo($className)->required, true)) { throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" should be required', $propertyName, $className)); } } diff --git a/src/Bridge/Doctrine/Common/DataPersister.php b/src/Bridge/Doctrine/Common/DataPersister.php index d66a20ec0f1..52ddf7096fe 100644 --- a/src/Bridge/Doctrine/Common/DataPersister.php +++ b/src/Bridge/Doctrine/Common/DataPersister.php @@ -81,6 +81,6 @@ public function remove($data) */ private function getManager($data) { - return is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null; + return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null; } } diff --git a/src/DataProvider/ChainItemDataProvider.php b/src/DataProvider/ChainItemDataProvider.php index 76180f57b86..4158d6b4339 100644 --- a/src/DataProvider/ChainItemDataProvider.php +++ b/src/DataProvider/ChainItemDataProvider.php @@ -46,7 +46,7 @@ public function getItem(string $resourceClass, $id, string $operationName = null return $dataProvider->getItem($resourceClass, $id, $operationName, $context); } catch (ResourceClassNotSupportedException $e) { - @trigger_error(sprintf('Throwing a "%s" is deprecated in favor of implementing "%s"', get_class($e), RestrictedDataProviderInterface::class), E_USER_DEPRECATED); + @trigger_error(sprintf('Throwing a "%s" is deprecated in favor of implementing "%s"', \get_class($e), RestrictedDataProviderInterface::class), E_USER_DEPRECATED); continue; } } diff --git a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php index 96ac9c92d13..95848ef0b7f 100644 --- a/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php +++ b/src/JsonApi/Serializer/ConstraintViolationListNormalizer.php @@ -71,7 +71,7 @@ private function getSourcePointerFromViolation(ConstraintViolationInterface $vio $propertyMetadata = $this->propertyMetadataFactory ->create( // Im quite sure this requires some thought in case of validations over relationships - get_class($violation->getRoot()), + \get_class($violation->getRoot()), $fieldName ); diff --git a/src/JsonApi/Serializer/ItemNormalizer.php b/src/JsonApi/Serializer/ItemNormalizer.php index 3f39e432f8e..0d0f754f0dd 100644 --- a/src/JsonApi/Serializer/ItemNormalizer.php +++ b/src/JsonApi/Serializer/ItemNormalizer.php @@ -67,7 +67,7 @@ public function normalize($object, $format = null, array $context = []) // Get and populate attributes data $objectAttributesData = parent::normalize($object, $format, $context); - if (!is_array($objectAttributesData)) { + if (!\is_array($objectAttributesData)) { return $objectAttributesData; } @@ -147,7 +147,7 @@ protected function getAttributes($object, $format = null, array $context) */ protected function setAttributeValue($object, $attribute, $value, $format = null, array $context = []) { - parent::setAttributeValue($object, $attribute, is_array($value) && array_key_exists('data', $value) ? $value['data'] : $value, $format, $context); + parent::setAttributeValue($object, $attribute, \is_array($value) && array_key_exists('data', $value) ? $value['data'] : $value, $format, $context); } /** @@ -164,7 +164,7 @@ protected function denormalizeRelation(string $attributeName, PropertyMetadata $ return $this->serializer->denormalize($value, $className, $format, $context); } - if (!is_array($value) || !isset($value['id'], $value['type'])) { + if (!\is_array($value) || !isset($value['id'], $value['type'])) { throw new InvalidArgumentException('Only resource linkage supported currently, see: http://jsonapi.org/format/#document-resource-object-linkage.'); } diff --git a/src/JsonApi/Serializer/ReservedAttributeNameConverter.php b/src/JsonApi/Serializer/ReservedAttributeNameConverter.php index a6b6649bd47..add93d79bf9 100644 --- a/src/JsonApi/Serializer/ReservedAttributeNameConverter.php +++ b/src/JsonApi/Serializer/ReservedAttributeNameConverter.php @@ -57,7 +57,7 @@ public function normalize($propertyName) */ public function denormalize($propertyName) { - if (in_array($propertyName, self::JSON_API_RESERVED_ATTRIBUTES, true)) { + if (\in_array($propertyName, self::JSON_API_RESERVED_ATTRIBUTES, true)) { $propertyName = substr($propertyName, 1); } diff --git a/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php b/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php index 4813f52c61c..ec29d11859c 100644 --- a/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php +++ b/src/Metadata/Resource/Factory/OperationResourceMetadataFactory.php @@ -107,7 +107,7 @@ private function normalize(bool $collection, ResourceMetadata $resourceMetadata, $newOperations = []; foreach ($operations as $operationName => $operation) { // e.g.: @ApiResource(itemOperations={"get"}) - if (is_int($operationName) && is_string($operation)) { + if (\is_int($operationName) && \is_string($operation)) { $operationName = $operation; $operation = []; } @@ -132,7 +132,7 @@ private function normalize(bool $collection, ResourceMetadata $resourceMetadata, private function normalizeGraphQl(ResourceMetadata $resourceMetadata, array $operations) { foreach ($operations as $operationName => $operation) { - if (is_int($operationName) && is_string($operation)) { + if (\is_int($operationName) && \is_string($operation)) { unset($operations[$operationName]); $operations[$operation] = []; } diff --git a/src/Serializer/AbstractCollectionNormalizer.php b/src/Serializer/AbstractCollectionNormalizer.php index 870e593eef9..8f5cd27e64d 100644 --- a/src/Serializer/AbstractCollectionNormalizer.php +++ b/src/Serializer/AbstractCollectionNormalizer.php @@ -49,7 +49,7 @@ public function __construct(ResourceClassResolverInterface $resourceClassResolve */ public function supportsNormalization($data, $format = null) { - return static::FORMAT === $format && (is_array($data) || $data instanceof \Traversable); + return static::FORMAT === $format && (\is_array($data) || $data instanceof \Traversable); } /** @@ -97,13 +97,13 @@ protected function getPaginationConfig($object, array $context = []): array $paginated = 1. !== $lastPage = $object->getLastPage(); $totalItems = $object->getTotalItems(); } else { - $pageTotalItems = (float) count($object); + $pageTotalItems = (float) \count($object); } $currentPage = $object->getCurrentPage(); $itemsPerPage = $object->getItemsPerPage(); - } elseif (is_array($object) || $object instanceof \Countable) { - $totalItems = count($object); + } elseif (\is_array($object) || $object instanceof \Countable) { + $totalItems = \count($object); } return [$paginator, $paginated, $currentPage, $itemsPerPage, $lastPage, $pageTotalItems, $totalItems]; diff --git a/src/Serializer/SerializerContextBuilder.php b/src/Serializer/SerializerContextBuilder.php index 74962da44ca..f760f08635b 100644 --- a/src/Serializer/SerializerContextBuilder.php +++ b/src/Serializer/SerializerContextBuilder.php @@ -69,7 +69,7 @@ public function createFromRequest(Request $request, bool $normalization, array $ $context['operation_type'] = $operationType ?: OperationType::ITEM; if (!$normalization && !isset($context['api_allow_update'])) { - $context['api_allow_update'] = in_array($request->getMethod(), ['PUT', 'PATCH'], true); + $context['api_allow_update'] = \in_array($request->getMethod(), ['PUT', 'PATCH'], true); } $context['resource_class'] = $attributes['resource_class']; diff --git a/src/Util/AnnotationFilterExtractorTrait.php b/src/Util/AnnotationFilterExtractorTrait.php index 2c0c4e60aa4..5109a109112 100644 --- a/src/Util/AnnotationFilterExtractorTrait.php +++ b/src/Util/AnnotationFilterExtractorTrait.php @@ -36,7 +36,7 @@ trait AnnotationFilterExtractorTrait private function getFilterAnnotations(array $miscAnnotations): \Iterator { foreach ($miscAnnotations as $miscAnnotation) { - if (ApiFilter::class === get_class($miscAnnotation)) { + if (ApiFilter::class === \get_class($miscAnnotation)) { yield $miscAnnotation; } } @@ -51,7 +51,7 @@ private function getFilterProperties(ApiFilter $filterAnnotation, \ReflectionCla if ($filterAnnotation->properties) { foreach ($filterAnnotation->properties as $property => $strategy) { - if (is_int($property)) { + if (\is_int($property)) { $properties[$strategy] = null; } else { $properties[$property] = $strategy; diff --git a/tests/Bridge/Doctrine/Orm/Extension/PaginationExtensionTest.php b/tests/Bridge/Doctrine/Orm/Extension/PaginationExtensionTest.php index 846c5a6f934..93831b122f6 100644 --- a/tests/Bridge/Doctrine/Orm/Extension/PaginationExtensionTest.php +++ b/tests/Bridge/Doctrine/Orm/Extension/PaginationExtensionTest.php @@ -463,7 +463,7 @@ private function getPaginationExtensionResult(bool $partial = false, bool $legac $queryBuilderProphecy->getRootEntities()->willReturn([])->shouldBeCalled(); $queryBuilderProphecy->getQuery()->willReturn($query)->shouldBeCalled(); $queryBuilderProphecy->getDQLPart(Argument::that(function ($arg) { - return in_array($arg, ['having', 'orderBy', 'join'], true); + return \in_array($arg, ['having', 'orderBy', 'join'], true); }))->willReturn('')->shouldBeCalled(); $queryBuilderProphecy->getMaxResults()->willReturn(42)->shouldBeCalled(); diff --git a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php index b571a61dc0f..eabda5f6dbe 100644 --- a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php +++ b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php @@ -287,7 +287,7 @@ public function testAddResourceClassDirectories() return $arg; } - if (!in_array('foobar', $arg, true)) { + if (!\in_array('foobar', $arg, true)) { throw new \Exception('"foobar" should be in "resource_class_directories"'); } diff --git a/tests/DataProvider/ChainCollectionDataProviderTest.php b/tests/DataProvider/ChainCollectionDataProviderTest.php index 80409906a8f..73ad9354624 100644 --- a/tests/DataProvider/ChainCollectionDataProviderTest.php +++ b/tests/DataProvider/ChainCollectionDataProviderTest.php @@ -69,7 +69,7 @@ public function testGetCollectionNotSupported() $collection = (new ChainCollectionDataProvider([$firstDataProvider->reveal()]))->getCollection('notfound', 'op'); - $this->assertTrue(is_array($collection) || $collection instanceof \Traversable); + $this->assertTrue(\is_array($collection) || $collection instanceof \Traversable); $this->assertEmpty($collection); } diff --git a/tests/Fixtures/TestBundle/Serializer/Denormalizer/SerializableResourceDenormalizer.php b/tests/Fixtures/TestBundle/Serializer/Denormalizer/SerializableResourceDenormalizer.php index d5da541faf0..812bc27ce5f 100644 --- a/tests/Fixtures/TestBundle/Serializer/Denormalizer/SerializableResourceDenormalizer.php +++ b/tests/Fixtures/TestBundle/Serializer/Denormalizer/SerializableResourceDenormalizer.php @@ -39,6 +39,6 @@ public function denormalize($data, $class, $format = null, array $context = []) */ public function supportsDenormalization($data, $type, $format = null) { - return 'json' === $format && SerializableResource::class === $type && is_array($data); + return 'json' === $format && SerializableResource::class === $type && \is_array($data); } } diff --git a/tests/JsonApi/Serializer/ItemNormalizerTest.php b/tests/JsonApi/Serializer/ItemNormalizerTest.php index 21d8b0858f3..38a2b7cab48 100644 --- a/tests/JsonApi/Serializer/ItemNormalizerTest.php +++ b/tests/JsonApi/Serializer/ItemNormalizerTest.php @@ -260,7 +260,7 @@ public function testDenormalize() )->shouldBeCalled(); $getItemFromIriSecondArgCallback = function ($arg) { - return is_array($arg) && isset($arg['fetch_data']) && true === $arg['fetch_data']; + return \is_array($arg) && isset($arg['fetch_data']) && true === $arg['fetch_data']; }; $iriConverterProphecy = $this->prophesize(IriConverterInterface::class); diff --git a/tests/Metadata/Resource/ResourceMetadataTest.php b/tests/Metadata/Resource/ResourceMetadataTest.php index 63ea67fd051..d699bc1f35d 100644 --- a/tests/Metadata/Resource/ResourceMetadataTest.php +++ b/tests/Metadata/Resource/ResourceMetadataTest.php @@ -73,9 +73,9 @@ public function testValueObject() public function testWithMethods(string $name, $value) { $metadata = new ResourceMetadata(); - $newMetadata = call_user_func([$metadata, "with$name"], $value); + $newMetadata = \call_user_func([$metadata, "with$name"], $value); $this->assertNotSame($metadata, $newMetadata); - $this->assertSame($value, call_user_func([$newMetadata, "get$name"])); + $this->assertSame($value, \call_user_func([$newMetadata, "get$name"])); } public function testGetOperationAttributeFallback()