From a0109b326ae230e9186a518f76be9a30d5c5b32d Mon Sep 17 00:00:00 2001 From: Vincent Chalamon Date: Mon, 8 Oct 2018 14:42:13 +0200 Subject: [PATCH] Fix CS --- src/Context/ApiContext.php | 4 ++-- src/Context/Argument/ArgumentResolver.php | 2 +- src/Helper/ApiHelper.php | 2 +- src/Populator/Guesser/ArrayGuesser.php | 2 +- src/Populator/Guesser/BooleanGuesser.php | 2 +- src/Populator/Guesser/CollectionGuesser.php | 2 +- src/Populator/Guesser/DateTimeGuesser.php | 2 +- src/Populator/Guesser/EntityGuesser.php | 2 +- src/Populator/Guesser/IntegerGuesser.php | 2 +- src/Populator/Guesser/StringGuesser.php | 2 +- src/Populator/Populator.php | 18 +++++++++--------- src/SchemaGenerator/ObjectSchemaGenerator.php | 2 +- .../TypeGenerator/ArrayTypeGenerator.php | 2 +- .../TypeGenerator/CollectionTypeGenerator.php | 2 +- .../TypeGenerator/DateTimeTypeGenerator.php | 2 +- .../TypeGenerator/DefaultTypeGenerator.php | 4 ++-- .../TypeGenerator/EntityTypeGenerator.php | 6 +++--- .../TypeGenerator/IntegerTypeGenerator.php | 2 +- .../TypeGenerator/NumberTypeGenerator.php | 2 +- .../TypeGenerator/StringTypeGenerator.php | 2 +- src/ServiceContainer/ApiConfigurator.php | 2 +- src/Transformer/ArrayTransformer.php | 2 +- src/Transformer/CollectionTransformer.php | 6 +++--- src/Transformer/DateTimeTransformer.php | 2 +- src/Transformer/EntityTransformer.php | 8 ++++---- src/Transformer/IntegerTransformer.php | 2 +- src/Transformer/StringTransformer.php | 2 +- 27 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/Context/ApiContext.php b/src/Context/ApiContext.php index f99b933..81050e6 100644 --- a/src/Context/ApiContext.php +++ b/src/Context/ApiContext.php @@ -322,7 +322,7 @@ public function validateItemJsonSchema(string $name, $schema = null) if (null === $schema) { $schema = $this->schemaGenerator->generate($this->helper->getReflectionClass($name), ['collection' => false, 'root' => true]); } - $this->jsonContext->theJsonShouldBeValidAccordingToThisSchema(new PyStringNode([is_array($schema) ? json_encode($schema) : $schema], 0)); + $this->jsonContext->theJsonShouldBeValidAccordingToThisSchema(new PyStringNode([\is_array($schema) ? json_encode($schema) : $schema], 0)); } /** @@ -347,7 +347,7 @@ public function validateCollectionJsonSchema(string $name, int $total = null, $s if (null === $schema) { $schema = $this->schemaGenerator->generate($this->helper->getReflectionClass($name), ['collection' => true, 'root' => true]); } - $this->jsonContext->theJsonShouldBeValidAccordingToThisSchema(new PyStringNode([is_array($schema) ? json_encode($schema) : $schema], 0)); + $this->jsonContext->theJsonShouldBeValidAccordingToThisSchema(new PyStringNode([\is_array($schema) ? json_encode($schema) : $schema], 0)); if (null !== $total) { $this->jsonContext->theJsonNodeShouldHaveElements('hydra:member', $total); } diff --git a/src/Context/Argument/ArgumentResolver.php b/src/Context/Argument/ArgumentResolver.php index 5da21e7..1ceb3b4 100644 --- a/src/Context/Argument/ArgumentResolver.php +++ b/src/Context/Argument/ArgumentResolver.php @@ -28,7 +28,7 @@ final class ArgumentResolver implements ArgumentResolverInterface public function __construct(/* ... */) { - $this->dependencies = func_get_args(); + $this->dependencies = \func_get_args(); } public function setMetadataFactory(ResourceMetadataFactoryInterface $metadataFactory) diff --git a/src/Helper/ApiHelper.php b/src/Helper/ApiHelper.php index d2a10a5..f5a338a 100644 --- a/src/Helper/ApiHelper.php +++ b/src/Helper/ApiHelper.php @@ -109,7 +109,7 @@ public function getReflectionClass(string $name): \ReflectionClass $classes = array_filter($allClasses, function (\ReflectionClass $reflectionClass) use ($result) { return strtolower($result) === strtolower($reflectionClass->getShortName()); }); - if (count($classes)) { + if (\count($classes)) { return array_shift($classes); } } diff --git a/src/Populator/Guesser/ArrayGuesser.php b/src/Populator/Guesser/ArrayGuesser.php index 4ca44ca..0ebb4d2 100755 --- a/src/Populator/Guesser/ArrayGuesser.php +++ b/src/Populator/Guesser/ArrayGuesser.php @@ -22,7 +22,7 @@ class ArrayGuesser extends AbstractGuesser { public function supports(array $mapping): bool { - return in_array($mapping['type'], [Type::TARRAY, Type::SIMPLE_ARRAY, Type::JSON_ARRAY], true); + return \in_array($mapping['type'], [Type::TARRAY, Type::SIMPLE_ARRAY, Type::JSON_ARRAY], true); } public function getValue(array $mapping): array diff --git a/src/Populator/Guesser/BooleanGuesser.php b/src/Populator/Guesser/BooleanGuesser.php index 97ac493..ba95dff 100755 --- a/src/Populator/Guesser/BooleanGuesser.php +++ b/src/Populator/Guesser/BooleanGuesser.php @@ -20,7 +20,7 @@ class BooleanGuesser extends AbstractGuesser { public function supports(array $mapping): bool { - return in_array($mapping['type'], ['boolean', 'bool'], true); + return \in_array($mapping['type'], ['boolean', 'bool'], true); } public function getValue(array $mapping): bool diff --git a/src/Populator/Guesser/CollectionGuesser.php b/src/Populator/Guesser/CollectionGuesser.php index 66ca8c9..58dc25f 100755 --- a/src/Populator/Guesser/CollectionGuesser.php +++ b/src/Populator/Guesser/CollectionGuesser.php @@ -33,7 +33,7 @@ public function setRegistry(ManagerRegistry $registry) public function supports(array $mapping): bool { - return null !== $mapping['targetEntity'] && in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY], true); + return null !== $mapping['targetEntity'] && \in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY], true); } public function getValue(array $mapping): array diff --git a/src/Populator/Guesser/DateTimeGuesser.php b/src/Populator/Guesser/DateTimeGuesser.php index 316ced1..73b042a 100755 --- a/src/Populator/Guesser/DateTimeGuesser.php +++ b/src/Populator/Guesser/DateTimeGuesser.php @@ -20,7 +20,7 @@ class DateTimeGuesser extends AbstractGuesser { public function supports(array $mapping): bool { - return in_array($mapping['type'], ['datetime', 'date', 'time'], true); + return \in_array($mapping['type'], ['datetime', 'date', 'time'], true); } public function getValue(array $mapping): \DateTime diff --git a/src/Populator/Guesser/EntityGuesser.php b/src/Populator/Guesser/EntityGuesser.php index 5553f83..054d55f 100755 --- a/src/Populator/Guesser/EntityGuesser.php +++ b/src/Populator/Guesser/EntityGuesser.php @@ -40,7 +40,7 @@ public function setRegistry(ManagerRegistry $registry) public function supports(array $mapping): bool { - return null !== $mapping['targetEntity'] && in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE], true); + return null !== $mapping['targetEntity'] && \in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE], true); } public function getValue(array $mapping) diff --git a/src/Populator/Guesser/IntegerGuesser.php b/src/Populator/Guesser/IntegerGuesser.php index e86af1d..35decee 100755 --- a/src/Populator/Guesser/IntegerGuesser.php +++ b/src/Populator/Guesser/IntegerGuesser.php @@ -20,7 +20,7 @@ class IntegerGuesser extends AbstractGuesser { public function supports(array $mapping): bool { - return in_array($mapping['type'], ['int', 'integer', 'smallint', 'bigint'], true); + return \in_array($mapping['type'], ['int', 'integer', 'smallint', 'bigint'], true); } public function getValue(array $mapping): int diff --git a/src/Populator/Guesser/StringGuesser.php b/src/Populator/Guesser/StringGuesser.php index abb76bd..c43cfb9 100755 --- a/src/Populator/Guesser/StringGuesser.php +++ b/src/Populator/Guesser/StringGuesser.php @@ -20,7 +20,7 @@ class StringGuesser extends AbstractGuesser { public function supports(array $mapping): bool { - return in_array($mapping['type'], ['string', 'text'], true); + return \in_array($mapping['type'], ['string', 'text'], true); } public function getValue(array $mapping): string diff --git a/src/Populator/Populator.php b/src/Populator/Populator.php index 3dd3520..d47d963 100644 --- a/src/Populator/Populator.php +++ b/src/Populator/Populator.php @@ -102,9 +102,9 @@ public function getObject(\ReflectionClass $reflectionClass, array $values = []) foreach ($values as $property => $value) { $value = $this->transformer->toObject($this->getMapping($classMetadata, $property), $value); if ($reflectionClass->hasMethod($property)) { - call_user_func([$object, $property], $value); + \call_user_func([$object, $property], $value); } elseif ($reflectionClass->hasMethod('set'.Inflector::camelize($property))) { - call_user_func([$object, 'set'.Inflector::camelize($property)], $value); + \call_user_func([$object, 'set'.Inflector::camelize($property)], $value); } elseif ($reflectionClass->hasProperty($property)) { $reflectionProperty = $reflectionClass->getProperty($property); $reflectionProperty->setAccessible(true); @@ -124,14 +124,14 @@ public function getRequestData(\ReflectionClass $reflectionClass, string $operat // Get serialization groups $resourceMetadata = $this->metadataFactory->create($className); $itemOperations = $this->filterOperations($resourceMetadata->getItemOperations() ?: ['get', 'put', 'delete'], $operation); - if (0 < count($itemOperations)) { + if (0 < \count($itemOperations)) { $methodName = 'getItemOperationAttribute'; } else { $methodName = 'getCollectionOperationAttribute'; } - $groups = array_merge($extraGroups, call_user_func([$resourceMetadata, $methodName], $operation, 'denormalization_context', [], true)['groups'] ?? []); - $validationGroups = call_user_func([$resourceMetadata, $methodName], $operation, 'validation_groups', ['Default'], true); - if (is_string($validationGroups)) { + $groups = array_merge($extraGroups, \call_user_func([$resourceMetadata, $methodName], $operation, 'denormalization_context', [], true)['groups'] ?? []); + $validationGroups = \call_user_func([$resourceMetadata, $methodName], $operation, 'validation_groups', ['Default'], true); + if (\is_string($validationGroups)) { $validationGroups = []; } $originalValues = $values; @@ -140,7 +140,7 @@ public function getRequestData(\ReflectionClass $reflectionClass, string $operat /** @var ClassMetadataInfo $classMetadata */ $classMetadata = $this->registry->getManagerForClass($className)->getClassMetadata($className); foreach ($this->propertyInfo->getProperties($className, $groups ? ['serializer_groups' => $groups] : []) as $property) { - if (!$reflectionClass->hasProperty($property) || !$this->isRequired($reflectionClass->getProperty($property), $validationGroups) || array_key_exists($property, $values) || ('put' === $operation && 0 < count($originalValues))) { + if (!$reflectionClass->hasProperty($property) || !$this->isRequired($reflectionClass->getProperty($property), $validationGroups) || array_key_exists($property, $values) || ('put' === $operation && 0 < \count($originalValues))) { continue; } $values[$property] = $this->guesser->getValue($this->getMapping($classMetadata, $property)); @@ -227,7 +227,7 @@ private function isRequired(\ReflectionProperty $reflectionProperty, $groups): b foreach ([NotBlank::class, NotNull::class, Count::class] as $class) { $annotation = $this->annotationReader->getPropertyAnnotation($reflectionProperty, $class); - if ($annotation && 0 < count(array_intersect($annotation->groups, $groups))) { + if ($annotation && 0 < \count(array_intersect($annotation->groups, $groups))) { return true; } } @@ -238,7 +238,7 @@ private function isRequired(\ReflectionProperty $reflectionProperty, $groups): b private function filterOperations(array $operations, string $operation): array { return array_filter($operations, function ($value, $key) use ($operation) { - return $operation === (is_int($key) ? $value : $key); + return $operation === (\is_int($key) ? $value : $key); }, ARRAY_FILTER_USE_BOTH); } } diff --git a/src/SchemaGenerator/ObjectSchemaGenerator.php b/src/SchemaGenerator/ObjectSchemaGenerator.php index 41254b1..87dfbd9 100644 --- a/src/SchemaGenerator/ObjectSchemaGenerator.php +++ b/src/SchemaGenerator/ObjectSchemaGenerator.php @@ -147,7 +147,7 @@ public function generate(\ReflectionClass $reflectionClass, array $context = []) if (false === ($mapping['nullable'] ?? true)) { $schema['required'][] = $property; } else { - if (!is_array($schema['properties'][$property]['type'])) { + if (!\is_array($schema['properties'][$property]['type'])) { $schema['properties'][$property]['type'] = [$schema['properties'][$property]['type']]; } $schema['properties'][$property]['type'][] = 'null'; diff --git a/src/SchemaGenerator/TypeGenerator/ArrayTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/ArrayTypeGenerator.php index df59657..0fcd7b9 100644 --- a/src/SchemaGenerator/TypeGenerator/ArrayTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/ArrayTypeGenerator.php @@ -22,7 +22,7 @@ final class ArrayTypeGenerator implements TypeGeneratorInterface { public function supports(array $mapping, array $context = []): bool { - return in_array($mapping['type'], [Type::TARRAY, Type::SIMPLE_ARRAY, Type::JSON_ARRAY], true); + return \in_array($mapping['type'], [Type::TARRAY, Type::SIMPLE_ARRAY, Type::JSON_ARRAY], true); } public function generate(array $mapping, array $context = []): array diff --git a/src/SchemaGenerator/TypeGenerator/CollectionTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/CollectionTypeGenerator.php index d431794..5c4210f 100644 --- a/src/SchemaGenerator/TypeGenerator/CollectionTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/CollectionTypeGenerator.php @@ -33,7 +33,7 @@ public function __construct(ContainerInterface $container = null) public function supports(array $mapping, array $context = []): bool { - return null !== $mapping['targetEntity'] && in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY], true); + return null !== $mapping['targetEntity'] && \in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY], true); } public function generate(array $mapping, array $context = []): array diff --git a/src/SchemaGenerator/TypeGenerator/DateTimeTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/DateTimeTypeGenerator.php index fb57c5b..be6a917 100644 --- a/src/SchemaGenerator/TypeGenerator/DateTimeTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/DateTimeTypeGenerator.php @@ -20,7 +20,7 @@ final class DateTimeTypeGenerator implements TypeGeneratorInterface { public function supports(array $mapping, array $context = []): bool { - return in_array($mapping['type'], ['datetime', 'date', 'time'], true); + return \in_array($mapping['type'], ['datetime', 'date', 'time'], true); } public function generate(array $mapping, array $context = []): array diff --git a/src/SchemaGenerator/TypeGenerator/DefaultTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/DefaultTypeGenerator.php index fa0f9d7..3b025c2 100644 --- a/src/SchemaGenerator/TypeGenerator/DefaultTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/DefaultTypeGenerator.php @@ -25,12 +25,12 @@ public function supports(array $mapping, array $context = []): bool public function generate(array $mapping, array $context = []): array { - if (!in_array($mapping['type'], ['integer', 'number', 'boolean', 'object', 'array', 'string', 'null', 'any'], true)) { + if (!\in_array($mapping['type'], ['integer', 'number', 'boolean', 'object', 'array', 'string', 'null', 'any'], true)) { $mapping['type'] = 'any'; } $type = ['type' => $mapping['type']]; if ($mapping['nullable'] ?? false) { - if (!is_array($type['type'])) { + if (!\is_array($type['type'])) { $type['type'] = [$type['type']]; } $type['type'][] = 'null'; diff --git a/src/SchemaGenerator/TypeGenerator/EntityTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/EntityTypeGenerator.php index efadd19..8dcfcfd 100644 --- a/src/SchemaGenerator/TypeGenerator/EntityTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/EntityTypeGenerator.php @@ -56,13 +56,13 @@ public function setAnnotationReader(Reader $reader) public function supports(array $mapping, array $context = []): bool { - return null !== $mapping['targetEntity'] && in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE], true); + return null !== $mapping['targetEntity'] && \in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE], true); } public function generate(array $mapping, array $context = []): array { $reflectionClass = new \ReflectionClass($mapping['targetEntity']); - if (0 < count($this->propertyInfo->getProperties($mapping['targetEntity'], $context))) { + if (0 < \count($this->propertyInfo->getProperties($mapping['targetEntity'], $context))) { $type = $this->container->get('schemaGenerator')->generate($reflectionClass, $context); } elseif ($this->reader->getClassAnnotation($reflectionClass, ApiResource::class)) { $type = [ @@ -73,7 +73,7 @@ public function generate(array $mapping, array $context = []): array throw new \LogicException('Entity '.$mapping['targetEntity'].' does not have any property to serialize with following groups: '.implode(', ', $context['serializer_groups'])); } if ($mapping['nullable'] ?? true) { - if (!is_array($type['type'])) { + if (!\is_array($type['type'])) { $type['type'] = [$type['type']]; } $type['type'][] = 'null'; diff --git a/src/SchemaGenerator/TypeGenerator/IntegerTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/IntegerTypeGenerator.php index 4c769f5..efbf86f 100644 --- a/src/SchemaGenerator/TypeGenerator/IntegerTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/IntegerTypeGenerator.php @@ -20,7 +20,7 @@ final class IntegerTypeGenerator implements TypeGeneratorInterface { public function supports(array $mapping, array $context = []): bool { - return in_array($mapping['type'], ['integer', 'smallint', 'bigint'], true); + return \in_array($mapping['type'], ['integer', 'smallint', 'bigint'], true); } public function generate(array $mapping, array $context = []): array diff --git a/src/SchemaGenerator/TypeGenerator/NumberTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/NumberTypeGenerator.php index de91659..b85d0a9 100644 --- a/src/SchemaGenerator/TypeGenerator/NumberTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/NumberTypeGenerator.php @@ -20,7 +20,7 @@ final class NumberTypeGenerator implements TypeGeneratorInterface { public function supports(array $mapping, array $context = []): bool { - return in_array($mapping['type'], ['int', 'float', 'decimal'], true); + return \in_array($mapping['type'], ['int', 'float', 'decimal'], true); } public function generate(array $mapping, array $context = []): array diff --git a/src/SchemaGenerator/TypeGenerator/StringTypeGenerator.php b/src/SchemaGenerator/TypeGenerator/StringTypeGenerator.php index 2052afe..290b71e 100644 --- a/src/SchemaGenerator/TypeGenerator/StringTypeGenerator.php +++ b/src/SchemaGenerator/TypeGenerator/StringTypeGenerator.php @@ -20,7 +20,7 @@ final class StringTypeGenerator implements TypeGeneratorInterface { public function supports(array $mapping, array $context = []): bool { - return in_array($mapping['type'], ['string', 'text'], true); + return \in_array($mapping['type'], ['string', 'text'], true); } public function generate(array $mapping, array $context = []): array diff --git a/src/ServiceContainer/ApiConfigurator.php b/src/ServiceContainer/ApiConfigurator.php index 2172266..e721b5d 100644 --- a/src/ServiceContainer/ApiConfigurator.php +++ b/src/ServiceContainer/ApiConfigurator.php @@ -47,7 +47,7 @@ public function configure($service) $value = $this->container->get('@' === substr($value, 0, 1) ? substr($value, 1) : $value); } } - call_user_func([$service, $methodName], $value); + \call_user_func([$service, $methodName], $value); } } } diff --git a/src/Transformer/ArrayTransformer.php b/src/Transformer/ArrayTransformer.php index 59087b9..44d2ed8 100644 --- a/src/Transformer/ArrayTransformer.php +++ b/src/Transformer/ArrayTransformer.php @@ -22,7 +22,7 @@ final class ArrayTransformer implements TransformerInterface { public function supports(array $mapping, $value): bool { - return in_array($mapping['type'], [Type::TARRAY, Type::JSON_ARRAY, Type::SIMPLE_ARRAY], true) && is_string($value); + return \in_array($mapping['type'], [Type::TARRAY, Type::JSON_ARRAY, Type::SIMPLE_ARRAY], true) && \is_string($value); } public function toObject(array $mapping, $value): array diff --git a/src/Transformer/CollectionTransformer.php b/src/Transformer/CollectionTransformer.php index dd25ac0..733fda9 100644 --- a/src/Transformer/CollectionTransformer.php +++ b/src/Transformer/CollectionTransformer.php @@ -38,7 +38,7 @@ public function setRegistry(ManagerRegistry $registry) public function supports(array $mapping, $value): bool { - return null !== $mapping['targetEntity'] && in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY], true); + return null !== $mapping['targetEntity'] && \in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_MANY, ClassMetadataInfo::MANY_TO_MANY], true); } public function toObject(array $mapping, $value): Collection @@ -47,7 +47,7 @@ public function toObject(array $mapping, $value): Collection return $value; } - if (is_array($value)) { + if (\is_array($value)) { return new ArrayCollection($value); } @@ -69,7 +69,7 @@ public function toObject(array $mapping, $value): Collection public function toScalar(array $mapping, $values): array { - if (!$values instanceof Collection && !is_array($values)) { + if (!$values instanceof Collection && !\is_array($values)) { $values = $this->toObject($mapping, $values); } if ($values instanceof Collection) { diff --git a/src/Transformer/DateTimeTransformer.php b/src/Transformer/DateTimeTransformer.php index 6577b3e..55e87f0 100644 --- a/src/Transformer/DateTimeTransformer.php +++ b/src/Transformer/DateTimeTransformer.php @@ -22,7 +22,7 @@ final class DateTimeTransformer implements TransformerInterface { public function supports(array $mapping, $value): bool { - return in_array($mapping['type'], [Type::DATETIME, Type::DATE, Type::TIME], true); + return \in_array($mapping['type'], [Type::DATETIME, Type::DATE, Type::TIME], true); } public function toObject(array $mapping, $value): \DateTime diff --git a/src/Transformer/EntityTransformer.php b/src/Transformer/EntityTransformer.php index 5d4b2d2..abffe05 100644 --- a/src/Transformer/EntityTransformer.php +++ b/src/Transformer/EntityTransformer.php @@ -48,7 +48,7 @@ public function setIriConverter(IriConverterInterface $iriConverter) public function supports(array $mapping, $value): bool { - return null !== $mapping['targetEntity'] && in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE], true); + return null !== $mapping['targetEntity'] && \in_array($mapping['type'], [ClassMetadataInfo::ONE_TO_ONE, ClassMetadataInfo::MANY_TO_ONE], true); } public function toObject(array $mapping, $value) @@ -83,7 +83,7 @@ public function toObject(array $mapping, $value) $type = 'integer'; break; } - if (gettype($value) === $type) { + if (\gettype($value) === $type) { $queryBuilder->orWhere("o.$fieldName = :query")->setParameter('query', $value); } } @@ -93,10 +93,10 @@ public function toObject(array $mapping, $value) public function toScalar(array $mapping, $value) { - if (is_array($value)) { + if (\is_array($value)) { return $value; } - if (!is_object($value)) { + if (!\is_object($value)) { $value = $this->toObject($mapping, $value); if (null === $value) { throw new EntityNotFoundException(sprintf('Unable to find an existing object of class %s with any value equal to %s.', $mapping['targetEntity'], $value)); diff --git a/src/Transformer/IntegerTransformer.php b/src/Transformer/IntegerTransformer.php index b44ad0a..858ef2c 100644 --- a/src/Transformer/IntegerTransformer.php +++ b/src/Transformer/IntegerTransformer.php @@ -22,7 +22,7 @@ final class IntegerTransformer implements TransformerInterface { public function supports(array $mapping, $value): bool { - return in_array($mapping['type'], ['int', Type::INTEGER, Type::SMALLINT, Type::BIGINT], true); + return \in_array($mapping['type'], ['int', Type::INTEGER, Type::SMALLINT, Type::BIGINT], true); } public function toObject(array $mapping, $value): int diff --git a/src/Transformer/StringTransformer.php b/src/Transformer/StringTransformer.php index 1211c80..4eaecf6 100644 --- a/src/Transformer/StringTransformer.php +++ b/src/Transformer/StringTransformer.php @@ -22,7 +22,7 @@ final class StringTransformer implements TransformerInterface { public function supports(array $mapping, $value): bool { - return in_array($mapping['type'], [Type::STRING, Type::TEXT], true); + return \in_array($mapping['type'], [Type::STRING, Type::TEXT], true); } public function toObject(array $mapping, $value): string