From 58eed4d90399a690e96c60c18e958d70e5b53c61 Mon Sep 17 00:00:00 2001 From: Dominik Zogg Date: Sun, 3 Oct 2021 13:22:04 +0200 Subject: [PATCH] update dev dependencies --- .php_cs => .php-cs-fixer.php | 11 ++++++-- composer.json | 6 ++--- phpstan.neon | 6 +++++ phpunit.xml | 15 ++++++----- src/Accessor/AccessorInterface.php | 4 +-- src/Accessor/MethodAccessor.php | 7 +++-- src/Accessor/PropertyAccessor.php | 11 +++----- src/Constraint/AllConstraint.php | 4 +-- src/Constraint/ChoiceConstraint.php | 2 +- src/Constraint/CoordinateArrayConstraint.php | 4 +-- src/Constraint/CoordinateConstraint.php | 4 +-- src/Constraint/CountConstraint.php | 6 ++--- src/Constraint/DateTimeConstraint.php | 10 +++---- src/Constraint/Doctrine/UniqueConstraint.php | 2 +- src/Constraint/EmailConstraint.php | 4 +-- src/Constraint/MapConstraint.php | 6 ++--- src/Constraint/NumericConstraint.php | 4 +-- src/Constraint/SortConstraint.php | 12 ++++----- .../Symfony/ConstraintViolationBuilder.php | 4 +-- src/Constraint/Symfony/ExecutionContext.php | 12 ++++----- src/Constraint/TypeConstraint.php | 4 +-- src/Constraint/ValidConstraint.php | 8 +++--- src/Error/ApiProblemErrorMessages.php | 2 +- src/Error/NestedErrorMessages.php | 2 +- .../CallableValidationMappingProvider.php | 7 ++--- src/Mapping/LazyValidationMappingProvider.php | 2 +- .../ValidationMappingProviderInterface.php | 2 +- .../ValidationMappingProviderRegistry.php | 2 +- src/Mapping/ValidationPropertyMapping.php | 4 +-- src/Validator.php | 18 +++++-------- tests/Integration/ValidatorTest.php | 14 +++------- tests/Unit/Constraint/AllConstraintTest.php | 14 +++++----- tests/Unit/Constraint/BlankConstraintTest.php | 2 +- .../Constraint/CallbackConstraintTest.php | 4 +-- .../Unit/Constraint/ChoiceConstraintTest.php | 2 +- .../CoordinateArrayConstraintTest.php | 2 +- .../Constraint/CoordinateConstraintTest.php | 2 +- tests/Unit/Constraint/CountConstraintTest.php | 2 +- .../Constraint/DateTimeConstraintTest.php | 10 +++---- .../Doctrine/UniqueConstraintTest.php | 22 ++++++++-------- tests/Unit/Constraint/EmailConstraintTest.php | 2 +- tests/Unit/Constraint/FalseConstraintTest.php | 2 +- tests/Unit/Constraint/MapConstraintTest.php | 17 ++++++------ .../Constraint/NotBlankConstraintTest.php | 2 +- .../Unit/Constraint/NotNullConstraintTest.php | 2 +- tests/Unit/Constraint/NullConstraintTest.php | 2 +- .../Unit/Constraint/NumericConstraintTest.php | 2 +- .../Constraint/NumericRangeConstraintTest.php | 2 +- tests/Unit/Constraint/SortConstraintTest.php | 10 +++---- .../Symfony/ConstraintAdapterTest.php | 2 +- .../Symfony/ExecutionContextTest.php | 2 +- tests/Unit/Constraint/TrueConstraintTest.php | 2 +- tests/Unit/Constraint/TypeConstraintTest.php | 6 ++--- tests/Unit/Constraint/ValidConstraintTest.php | 4 +-- .../Error/ApiProblemErrorMessagesTest.php | 2 +- tests/Unit/Error/ErrorMessagesTest.php | 2 +- tests/Unit/Error/NestedErrorMessagesTest.php | 2 +- .../LazyValidationMappingProviderTest.php | 8 +++--- .../ValidationClassMappingBuilderTest.php | 2 +- .../Mapping/ValidationClassMappingTest.php | 2 +- .../ValidationMappingProviderRegistryTest.php | 14 +++++----- .../ValidationPropertyMappingBuilderTest.php | 4 +-- .../Mapping/ValidationPropertyMappingTest.php | 4 +-- tests/Unit/ValidatorTest.php | 26 +++++++++---------- 64 files changed, 187 insertions(+), 195 deletions(-) rename .php_cs => .php-cs-fixer.php (62%) diff --git a/.php_cs b/.php-cs-fixer.php similarity index 62% rename from .php_cs rename to .php-cs-fixer.php index 0469f19..3ed6af6 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -12,9 +12,16 @@ /** @var array $config */ $config = require __DIR__ . '/vendor/chubbyphp/chubbyphp-dev-helper/phpcs.php'; -unset ($config['rules']['final_class']); +unset($config['rules']['final_class']); -return PhpCsFixer\Config::create() +$config['rules']['final_public_method_for_abstract_class'] = false; + +// drop onces code is >= 8.0 +unset($config['rules']['phpdoc_to_return_type']); + +$config['rules']['phpdoc_to_param_type'] = false; + +return (new PhpCsFixer\Config) ->setIndent($config['indent']) ->setLineEnding($config['lineEnding']) ->setRules($config['rules']) diff --git a/composer.json b/composer.json index 6781a13..33abe30 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,12 @@ "chubbyphp/chubbyphp-laminas-config-factory": "^1.0", "chubbyphp/chubbyphp-mock": "^1.6", "doctrine/persistence": "^1.3|^2.0", - "infection/infection": "^0.20.2", + "infection/infection": "^0.25.2", "php-coveralls/php-coveralls": "^2.4.3", "phploc/phploc": "^7.0.2", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^0.12.64", - "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^0.12.99", + "phpunit/phpunit": "^9.5.10", "pimple/pimple": "^3.3", "psr/container": "^1.0|^2.0", "symfony/validator": "^3.4|^4.2|^5.0" diff --git a/phpstan.neon b/phpstan.neon index 66248a5..2873e47 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,3 +6,9 @@ parameters: - message: '/PHPDoc tag @var for variable \$parentReflectionClass contains generic class ReflectionClass but does not specify its types\: T/' path: %currentWorkingDirectory%/src/Mapping/ValidationMappingProviderRegistry.php + - + message: '/Method Chubbyphp\\Validation\\Constraint\\Symfony\\ExecutionContext\:\:getObject\(\) should return object\|null but return statement is missing\./' + path: %currentWorkingDirectory%/src/Constraint/Symfony/ExecutionContext.php + - + message: '/Method Chubbyphp\\Validation\\Constraint\\Symfony\\ExecutionContext\:\:getClassName\(\) should return string\|null but return statement is missing\./' + path: %currentWorkingDirectory%/src/Constraint/Symfony/ExecutionContext.php diff --git a/phpunit.xml b/phpunit.xml index e13e7e7..4ea36f1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,6 @@ - + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> + + + ./src + + ./tests/Integration @@ -17,9 +23,4 @@ ./tests/Unit - - - ./src - - diff --git a/src/Accessor/AccessorInterface.php b/src/Accessor/AccessorInterface.php index 80b2810..248e60a 100644 --- a/src/Accessor/AccessorInterface.php +++ b/src/Accessor/AccessorInterface.php @@ -9,11 +9,9 @@ interface AccessorInterface { /** - * @param object $object - * * @throws ValidatorLogicException * * @return mixed */ - public function getValue($object); + public function getValue(object $object); } diff --git a/src/Accessor/MethodAccessor.php b/src/Accessor/MethodAccessor.php index 231e5e7..8cd1b16 100644 --- a/src/Accessor/MethodAccessor.php +++ b/src/Accessor/MethodAccessor.php @@ -16,13 +16,11 @@ public function __construct(string $property) } /** - * @param object $object - * * @throws ValidatorLogicException * * @return mixed */ - public function getValue($object) + public function getValue(object $object) { $getMethodName = 'get'.ucfirst($this->property); $hasMethodName = 'has'.ucfirst($this->property); @@ -41,7 +39,8 @@ public function getValue($object) } throw ValidatorLogicException::createMissingMethod( - get_class($object), [$getMethodName, $hasMethodName, $isMethodName] + \get_class($object), + [$getMethodName, $hasMethodName, $isMethodName] ); } } diff --git a/src/Accessor/PropertyAccessor.php b/src/Accessor/PropertyAccessor.php index adbd497..0d9e356 100644 --- a/src/Accessor/PropertyAccessor.php +++ b/src/Accessor/PropertyAccessor.php @@ -17,11 +17,9 @@ public function __construct(string $property) } /** - * @param object $object - * * @return mixed */ - public function getValue($object) + public function getValue(object $object) { $class = $this->getClass($object); @@ -38,10 +36,7 @@ public function getValue($object) return $getter($this->property); } - /** - * @param object $object - */ - private function getClass($object): string + private function getClass(object $object): string { if (interface_exists('Doctrine\Persistence\Proxy') && $object instanceof Proxy) { if (!$object->__isInitialized()) { @@ -54,6 +49,6 @@ private function getClass($object): string } } - return get_class($object); + return \get_class($object); } } diff --git a/src/Constraint/AllConstraint.php b/src/Constraint/AllConstraint.php index 67dde5c..55e76c3 100644 --- a/src/Constraint/AllConstraint.php +++ b/src/Constraint/AllConstraint.php @@ -45,11 +45,11 @@ public function validate( return []; } - if (!is_array($value) && !$value instanceof \Traversable) { + if (!\is_array($value) && !$value instanceof \Traversable) { return [new Error( $path.'[_all]', 'constraint.all.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } diff --git a/src/Constraint/ChoiceConstraint.php b/src/Constraint/ChoiceConstraint.php index 550190b..65a4fb9 100644 --- a/src/Constraint/ChoiceConstraint.php +++ b/src/Constraint/ChoiceConstraint.php @@ -39,7 +39,7 @@ public function validate( return []; } - if (!in_array($value, $this->choices, true)) { + if (!\in_array($value, $this->choices, true)) { return [ new Error( $path, diff --git a/src/Constraint/CoordinateArrayConstraint.php b/src/Constraint/CoordinateArrayConstraint.php index 3944d78..07e8593 100644 --- a/src/Constraint/CoordinateArrayConstraint.php +++ b/src/Constraint/CoordinateArrayConstraint.php @@ -26,11 +26,11 @@ public function validate( return []; } - if (!is_array($value)) { + if (!\is_array($value)) { return [new Error( $path, 'constraint.coordinatearray.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } diff --git a/src/Constraint/CoordinateConstraint.php b/src/Constraint/CoordinateConstraint.php index 6bd100d..055cbfb 100644 --- a/src/Constraint/CoordinateConstraint.php +++ b/src/Constraint/CoordinateConstraint.php @@ -28,11 +28,11 @@ public function validate( return []; } - if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { return [new Error( $path, 'constraint.coordinate.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } diff --git a/src/Constraint/CountConstraint.php b/src/Constraint/CountConstraint.php index 5d46899..5bb4845 100644 --- a/src/Constraint/CountConstraint.php +++ b/src/Constraint/CountConstraint.php @@ -36,15 +36,15 @@ public function validate( return []; } - if (!is_array($value) && !$value instanceof \Countable) { + if (!\is_array($value) && !$value instanceof \Countable) { return [new Error( $path, 'constraint.count.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } - $count = count($value); + $count = \count($value); if (null !== $this->min && $count < $this->min || null !== $this->max && $count > $this->max) { return [ diff --git a/src/Constraint/DateTimeConstraint.php b/src/Constraint/DateTimeConstraint.php index 1ff6495..07d534f 100644 --- a/src/Constraint/DateTimeConstraint.php +++ b/src/Constraint/DateTimeConstraint.php @@ -37,19 +37,19 @@ public function validate( return $this->validateDateTime($path, $value); } - if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { return [new Error( $path, 'constraint.datetime.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } $value = trim((string) $value); - \DateTime::createFromFormat('!'.$this->format, $value); + \DateTimeImmutable::createFromFormat('!'.$this->format, $value); - $dateTimeErrors = \DateTime::getLastErrors(); + $dateTimeErrors = \DateTimeImmutable::getLastErrors(); return [...$this->errorsByDateTimeLastErrors( $path, @@ -72,7 +72,7 @@ public function validate( private function validateDateTime(string $path, \DateTimeInterface $value): array { /** @var \DateTime $expectedValue */ - $expectedValue = \DateTime::createFromFormat( + $expectedValue = \DateTimeImmutable::createFromFormat( '!'.$this->format, $value->format($this->format), $value->getTimezone() diff --git a/src/Constraint/Doctrine/UniqueConstraint.php b/src/Constraint/Doctrine/UniqueConstraint.php index f223e4a..f451934 100644 --- a/src/Constraint/Doctrine/UniqueConstraint.php +++ b/src/Constraint/Doctrine/UniqueConstraint.php @@ -47,7 +47,7 @@ public function validate( $criteria = $this->getCriteria($model); - $modelClass = get_class($model); + $modelClass = \get_class($model); if (null === $persistedModel = $this->objectManager->getRepository($modelClass)->findOneBy($criteria)) { return []; diff --git a/src/Constraint/EmailConstraint.php b/src/Constraint/EmailConstraint.php index 2877b78..a26a406 100644 --- a/src/Constraint/EmailConstraint.php +++ b/src/Constraint/EmailConstraint.php @@ -31,11 +31,11 @@ public function validate( return []; } - if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { return [new Error( $path, 'constraint.email.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } diff --git a/src/Constraint/MapConstraint.php b/src/Constraint/MapConstraint.php index 719f54e..538c44e 100644 --- a/src/Constraint/MapConstraint.php +++ b/src/Constraint/MapConstraint.php @@ -18,7 +18,7 @@ final class MapConstraint implements ConstraintInterface private array $constraintsByFields; /** - * @param array> $constraintsByFields + * @param array|ConstraintInterface> $constraintsByFields */ public function __construct(array $constraintsByFields = []) { @@ -58,11 +58,11 @@ public function validate( return []; } - if (!is_array($value) && !$value instanceof \Traversable) { + if (!\is_array($value) && !$value instanceof \Traversable) { return [new Error( $path, 'constraint.map.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } diff --git a/src/Constraint/NumericConstraint.php b/src/Constraint/NumericConstraint.php index 80495bd..170626c 100644 --- a/src/Constraint/NumericConstraint.php +++ b/src/Constraint/NumericConstraint.php @@ -26,11 +26,11 @@ public function validate( return []; } - if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) { + if (!is_scalar($value) && !(\is_object($value) && method_exists($value, '__toString'))) { return [new Error( $path, 'constraint.numeric.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } diff --git a/src/Constraint/SortConstraint.php b/src/Constraint/SortConstraint.php index c988b60..52ab426 100644 --- a/src/Constraint/SortConstraint.php +++ b/src/Constraint/SortConstraint.php @@ -40,11 +40,11 @@ public function validate( ValidatorContextInterface $context, ?ValidatorInterface $validator = null ): array { - if (!is_array($sort)) { + if (!\is_array($sort)) { return [new Error( $path, 'constraint.sort.invalidtype', - ['type' => is_object($sort) ? get_class($sort) : gettype($sort)] + ['type' => \is_object($sort) ? \get_class($sort) : \gettype($sort)] )]; } @@ -66,7 +66,7 @@ private function validateFieldAndOrder(string $path, string $field, $order): arr { $errors = []; - if (!in_array($field, $this->allowedFields, true)) { + if (!\in_array($field, $this->allowedFields, true)) { $errors[] = new Error( $path.'.'.$field, 'constraint.sort.field.notallowed', @@ -74,17 +74,17 @@ private function validateFieldAndOrder(string $path, string $field, $order): arr ); } - if (!is_string($order)) { + if (!\is_string($order)) { $errors[] = new Error( $path.'.'.$field, 'constraint.sort.order.invalidtype', - ['field' => $field, 'type' => is_object($order) ? get_class($order) : gettype($order)] + ['field' => $field, 'type' => \is_object($order) ? \get_class($order) : \gettype($order)] ); return $errors; } - if (!in_array($order, self::ALLOWED_ORDERS, true)) { + if (!\in_array($order, self::ALLOWED_ORDERS, true)) { $errors[] = new Error( $path.'.'.$field, 'constraint.sort.order.notallowed', diff --git a/src/Constraint/Symfony/ConstraintViolationBuilder.php b/src/Constraint/Symfony/ConstraintViolationBuilder.php index 69a685d..58d756e 100644 --- a/src/Constraint/Symfony/ConstraintViolationBuilder.php +++ b/src/Constraint/Symfony/ConstraintViolationBuilder.php @@ -14,7 +14,7 @@ final class ConstraintViolationBuilder implements ConstraintViolationBuilderInte /** * @var ConstraintViolationListInterface */ - private $violations; + private ConstraintViolationListInterface $violations; private string $path; @@ -128,7 +128,7 @@ public function setPlural($number): self } /** - * @param string|null $code + * @param null|string $code * * @return ConstraintViolationBuilder */ diff --git a/src/Constraint/Symfony/ExecutionContext.php b/src/Constraint/Symfony/ExecutionContext.php index 717c6ca..e0fe8dd 100644 --- a/src/Constraint/Symfony/ExecutionContext.php +++ b/src/Constraint/Symfony/ExecutionContext.php @@ -67,16 +67,15 @@ public function getValidator() } /** - * @return object|null + * @return null|object */ public function getObject() { - return null; } /** * @param mixed $value - * @param object|null $object + * @param null|object $object * @param string $propertyPath */ public function setNode($value, $object, ?MetadataInterface $metadata, $propertyPath): void @@ -85,7 +84,7 @@ public function setNode($value, $object, ?MetadataInterface $metadata, $property } /** - * @param string|null $group + * @param null|string $group */ public function setGroup($group): void { @@ -172,7 +171,7 @@ public function getValue() } /** - * @return MetadataInterface|null + * @return null|MetadataInterface */ public function getMetadata() { @@ -189,11 +188,10 @@ public function getGroup(): string } /** - * @return string|null + * @return null|string */ public function getClassName() { - return null; } public function getPropertyName(): string diff --git a/src/Constraint/TypeConstraint.php b/src/Constraint/TypeConstraint.php index c70c59b..1491bab 100644 --- a/src/Constraint/TypeConstraint.php +++ b/src/Constraint/TypeConstraint.php @@ -33,14 +33,14 @@ public function validate( return []; } - $type = gettype($value); + $type = \gettype($value); if ('object' === $type) { if ($value instanceof $this->wishedType) { return []; } - return [$this->getInvalidTypeErrorByPathAndType($path, get_class($value))]; + return [$this->getInvalidTypeErrorByPathAndType($path, \get_class($value))]; } if ($type === $this->wishedType) { diff --git a/src/Constraint/ValidConstraint.php b/src/Constraint/ValidConstraint.php index 585e0b6..77c93be 100644 --- a/src/Constraint/ValidConstraint.php +++ b/src/Constraint/ValidConstraint.php @@ -33,7 +33,7 @@ public function validate( throw ValidatorLogicException::createMissingValidator($path); } - if (is_array($value) || $value instanceof \Traversable) { + if (\is_array($value) || $value instanceof \Traversable) { $errors = []; foreach ($value as $i => $subValue) { $errors = array_merge($errors, $validator->validate($subValue, $context, $path.'['.$i.']')); @@ -42,14 +42,14 @@ public function validate( return $errors; } - if (is_object($value)) { + if (\is_object($value)) { return $validator->validate($value, $context, $path); } return [new Error( - $path, + $path, 'constraint.valid.invalidtype', - ['type' => is_object($value) ? get_class($value) : gettype($value)] + ['type' => \is_object($value) ? \get_class($value) : \gettype($value)] )]; } } diff --git a/src/Error/ApiProblemErrorMessages.php b/src/Error/ApiProblemErrorMessages.php index b599b5b..32fb245 100644 --- a/src/Error/ApiProblemErrorMessages.php +++ b/src/Error/ApiProblemErrorMessages.php @@ -12,7 +12,7 @@ final class ApiProblemErrorMessages implements ErrorMessagesInterface private array $errors; /** - * @var array>|null + * @var null|array> */ private ?array $errorMessages = null; diff --git a/src/Error/NestedErrorMessages.php b/src/Error/NestedErrorMessages.php index 3377d50..c4b0345 100644 --- a/src/Error/NestedErrorMessages.php +++ b/src/Error/NestedErrorMessages.php @@ -17,7 +17,7 @@ final class NestedErrorMessages implements ErrorMessagesInterface private $translate; /** - * @var array|null + * @var null|array */ private ?array $nestedErrorMessages = null; diff --git a/src/Mapping/CallableValidationMappingProvider.php b/src/Mapping/CallableValidationMappingProvider.php index 0f0fee2..8c78f31 100644 --- a/src/Mapping/CallableValidationMappingProvider.php +++ b/src/Mapping/CallableValidationMappingProvider.php @@ -13,10 +13,7 @@ final class CallableValidationMappingProvider implements ValidationMappingProvid */ private $callable; - /** - * @var ValidationMappingProviderInterface|null - */ - private $mapping; + private ?ValidationMappingProviderInterface $mapping = null; public function __construct(string $class, callable $callable) { @@ -30,7 +27,7 @@ public function getClass(): string } /** - * @return ValidationClassMappingInterface|null + * @return null|ValidationClassMappingInterface */ public function getValidationClassMapping(string $path) { diff --git a/src/Mapping/LazyValidationMappingProvider.php b/src/Mapping/LazyValidationMappingProvider.php index 68a33cd..e4f9360 100644 --- a/src/Mapping/LazyValidationMappingProvider.php +++ b/src/Mapping/LazyValidationMappingProvider.php @@ -30,7 +30,7 @@ public function getClass(): string } /** - * @return ValidationClassMappingInterface|null + * @return null|ValidationClassMappingInterface */ public function getValidationClassMapping(string $path) { diff --git a/src/Mapping/ValidationMappingProviderInterface.php b/src/Mapping/ValidationMappingProviderInterface.php index b0e9f61..8031cbc 100644 --- a/src/Mapping/ValidationMappingProviderInterface.php +++ b/src/Mapping/ValidationMappingProviderInterface.php @@ -9,7 +9,7 @@ interface ValidationMappingProviderInterface public function getClass(): string; /** - * @return ValidationClassMappingInterface|null + * @return null|ValidationClassMappingInterface */ public function getValidationClassMapping(string $path); diff --git a/src/Mapping/ValidationMappingProviderRegistry.php b/src/Mapping/ValidationMappingProviderRegistry.php index 214881d..a4e326d 100644 --- a/src/Mapping/ValidationMappingProviderRegistry.php +++ b/src/Mapping/ValidationMappingProviderRegistry.php @@ -33,7 +33,7 @@ public function provideMapping(string $class): ValidationMappingProviderInterfac { $reflectionClass = new \ReflectionClass($class); - if (in_array('Doctrine\Persistence\Proxy', $reflectionClass->getInterfaceNames(), true)) { + if (\in_array('Doctrine\Persistence\Proxy', $reflectionClass->getInterfaceNames(), true)) { /** @var \ReflectionClass $parentReflectionClass */ $parentReflectionClass = $reflectionClass->getParentClass(); $class = $parentReflectionClass->getName(); diff --git a/src/Mapping/ValidationPropertyMapping.php b/src/Mapping/ValidationPropertyMapping.php index 523f101..11c400d 100644 --- a/src/Mapping/ValidationPropertyMapping.php +++ b/src/Mapping/ValidationPropertyMapping.php @@ -31,8 +31,8 @@ public function __construct( string $name, array $constraints, array $groups, - AccessorInterface $accessor) - { + AccessorInterface $accessor + ) { $this->name = $name; $this->constraints = $constraints; $this->groups = $groups; diff --git a/src/Validator.php b/src/Validator.php index a444622..cb67048 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -35,7 +35,7 @@ public function validate(object $object, ?ValidatorContextInterface $context = n { $context ??= ValidatorContextBuilder::create()->getContext(); - $class = get_class($object); + $class = \get_class($object); $objectMapping = $this->getObjectMapping($class); @@ -73,15 +73,13 @@ private function getObjectMapping(string $class): ValidationMappingProviderInter } /** - * @param object $object - * * @return array */ private function validateClass( ValidatorContextInterface $context, ?ValidationClassMappingInterface $classMapping, string $path, - $object + object $object ) { if (null === $classMapping) { return []; @@ -108,15 +106,13 @@ private function validateClass( } /** - * @param object $object - * * @return array */ private function validateProperty( ValidatorContextInterface $context, ValidationPropertyMappingInterface $propertyMapping, string $path, - $object + object $object ): array { if (!$this->isWithinGroup($context, $propertyMapping)) { return []; @@ -153,7 +149,7 @@ private function isWithinGroup( } foreach ($mapping->getGroups() as $group) { - if (in_array($group, $groups, true)) { + if (\in_array($group, $groups, true)) { return true; } } @@ -162,7 +158,7 @@ private function isWithinGroup( } /** - * @param string|int $name + * @param int|string $name */ private function getSubPathByName(string $path, $name): string { @@ -178,7 +174,7 @@ private function logConstraint(string $path, ConstraintInterface $constraint): v { $this->logger->debug('validate: path {path}, constraint {constraint}', [ 'path' => $path, - 'constraint' => get_class($constraint), + 'constraint' => \get_class($constraint), ]); } @@ -186,7 +182,7 @@ private function logError(string $path, ConstraintInterface $constraint, ErrorIn { $this->logger->notice('validate: path {path}, constraint {constraint}, error {error}', [ 'path' => $path, - 'constraint' => get_class($constraint), + 'constraint' => \get_class($constraint), 'error' => [ 'key' => $error->getKey(), 'arguments' => $error->getArguments(), diff --git a/tests/Integration/ValidatorTest.php b/tests/Integration/ValidatorTest.php index ad95054..86627dd 100644 --- a/tests/Integration/ValidatorTest.php +++ b/tests/Integration/ValidatorTest.php @@ -38,10 +38,7 @@ public function testValidator(): void $object = new class() { private ?string $notBlank = null; - /** - * @var int - */ - private $numeric; + private int $numeric; private ?string $callback = null; @@ -108,17 +105,14 @@ public function setAll(\ArrayIterator $all): self new class($object) implements ValidationMappingProviderInterface { private object $object; - /** - * @param object $object - */ - public function __construct($object) + public function __construct(object $object) { $this->object = $object; } public function getClass(): string { - return get_class($this->object); + return \get_class($this->object); } public function getValidationClassMapping(string $path): ValidationClassMappingInterface @@ -129,7 +123,7 @@ public function getValidationClassMapping(string $path): ValidationClassMappingI /** * @return ValidationPropertyMappingInterface[] */ - public function getValidationPropertyMappings(string $path, string $type = null): array + public function getValidationPropertyMappings(string $path, ?string $type = null): array { return [ ValidationPropertyMappingBuilder::create('notBlank', [ diff --git a/tests/Unit/Constraint/AllConstraintTest.php b/tests/Unit/Constraint/AllConstraintTest.php index 3400847..3567f9e 100644 --- a/tests/Unit/Constraint/AllConstraintTest.php +++ b/tests/Unit/Constraint/AllConstraintTest.php @@ -64,7 +64,7 @@ public function testWithConstraintAndError(): void private function getValidator(): ValidatorInterface { - /* @var ValidatorInterface|MockObject $validator */ + // @var ValidatorInterface|MockObject $validator return $this->getMockByCalls(ValidatorInterface::class); } @@ -79,11 +79,11 @@ private function getConstraint(bool $error = false): ConstraintInterface $constraint->expects(self::any())->method('validate')->willReturnCallback( static function ( - string $path, - $value, - ValidatorContextInterface $context, - ValidatorInterface $validator = null - ) use ($error) { + string $path, + $value, + ValidatorContextInterface $context, + ?ValidatorInterface $validator = null + ) use ($error) { if (!$error) { return []; } @@ -97,7 +97,7 @@ static function ( private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/BlankConstraintTest.php b/tests/Unit/Constraint/BlankConstraintTest.php index b36104e..f485215 100644 --- a/tests/Unit/Constraint/BlankConstraintTest.php +++ b/tests/Unit/Constraint/BlankConstraintTest.php @@ -80,7 +80,7 @@ public function testWithNotBlankStdClass(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/CallbackConstraintTest.php b/tests/Unit/Constraint/CallbackConstraintTest.php index fa6a04b..5e2201f 100644 --- a/tests/Unit/Constraint/CallbackConstraintTest.php +++ b/tests/Unit/Constraint/CallbackConstraintTest.php @@ -43,7 +43,7 @@ private function getCallback(): callable string $path, $value, ValidatorContextInterface $context, - ValidatorInterface $validator = null + ?ValidatorInterface $validator = null ) { if (null === $value) { return []; @@ -57,7 +57,7 @@ private function getCallback(): callable private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/ChoiceConstraintTest.php b/tests/Unit/Constraint/ChoiceConstraintTest.php index 8506f7a..c483837 100644 --- a/tests/Unit/Constraint/ChoiceConstraintTest.php +++ b/tests/Unit/Constraint/ChoiceConstraintTest.php @@ -84,7 +84,7 @@ private function implode(array $choices): string private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/CoordinateArrayConstraintTest.php b/tests/Unit/Constraint/CoordinateArrayConstraintTest.php index 4fbe874..8458563 100644 --- a/tests/Unit/Constraint/CoordinateArrayConstraintTest.php +++ b/tests/Unit/Constraint/CoordinateArrayConstraintTest.php @@ -89,7 +89,7 @@ public function getInvalidCoordinateArrays(): array private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/CoordinateConstraintTest.php b/tests/Unit/Constraint/CoordinateConstraintTest.php index 028e377..952a2d2 100644 --- a/tests/Unit/Constraint/CoordinateConstraintTest.php +++ b/tests/Unit/Constraint/CoordinateConstraintTest.php @@ -108,7 +108,7 @@ public function getInvalidCoordinates(): array private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/CountConstraintTest.php b/tests/Unit/Constraint/CountConstraintTest.php index 690be2c..60989e3 100644 --- a/tests/Unit/Constraint/CountConstraintTest.php +++ b/tests/Unit/Constraint/CountConstraintTest.php @@ -102,7 +102,7 @@ public function testWithMinAndMaxToManyValues(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/DateTimeConstraintTest.php b/tests/Unit/Constraint/DateTimeConstraintTest.php index 7b614e3..f284b34 100644 --- a/tests/Unit/Constraint/DateTimeConstraintTest.php +++ b/tests/Unit/Constraint/DateTimeConstraintTest.php @@ -38,7 +38,7 @@ public function testWithDate(): void { $constraint = new DateTimeConstraint('Y-m-d'); - $date = new \DateTime('2018-05-21'); + $date = new \DateTimeImmutable('2018-05-21'); $date->setTime(0, 0, 0); self::assertEquals([], $constraint->validate('date', $date, $this->getContext())); @@ -48,8 +48,8 @@ public function testWithDateTimeExpectedDate(): void { $constraint = new DateTimeConstraint('Y-m-d'); - $date = new \DateTime('2018-05-21T00:00:00+02:00'); - $date->setTime(2, 0, 0); + $date = new \DateTimeImmutable('2018-05-21T00:00:00+02:00'); + $date = $date->setTime(2, 0, 0); $error = new Error( 'date', @@ -67,7 +67,7 @@ public function testWithDateTime(): void { $constraint = new DateTimeConstraint(); - $date = new \DateTime('2018-05-21'); + $date = new \DateTimeImmutable('2018-05-21'); $date->setTime(2, 0, 0); self::assertEquals([], $constraint->validate('date', $date, $this->getContext())); @@ -149,7 +149,7 @@ public function testWithInvalidDateTimeFormat(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/Doctrine/UniqueConstraintTest.php b/tests/Unit/Constraint/Doctrine/UniqueConstraintTest.php index 5e602f5..ccb0c1f 100644 --- a/tests/Unit/Constraint/Doctrine/UniqueConstraintTest.php +++ b/tests/Unit/Constraint/Doctrine/UniqueConstraintTest.php @@ -26,7 +26,7 @@ final class UniqueConstraintTest extends TestCase public function testWithNullValue(): void { - /** @var ObjectManager|MockObject $objectManager */ + /** @var MockObject|ObjectManager $objectManager */ $objectManager = $this->getMockByCalls(ObjectManager::class); $constraint = new UniqueConstraint($objectManager, ['name']); @@ -41,14 +41,14 @@ public function testWithNewModel(): void private string $name = 'name'; }; - $modelClass = get_class($model); + $modelClass = \get_class($model); - /** @var ObjectRepository|MockObject $repository */ + /** @var MockObject|ObjectRepository $repository */ $repository = $this->getMockByCalls(ObjectRepository::class, [ Call::create('findOneBy')->with(['name' => 'name'])->willReturn(null), ]); - /** @var ObjectManager|MockObject $objectManager */ + /** @var MockObject|ObjectManager $objectManager */ $objectManager = $this->getMockByCalls(ObjectManager::class, [ Call::create('getRepository')->with($modelClass)->willReturn($repository), ]); @@ -65,9 +65,9 @@ public function testWithSameExistingModel(): void private string $name = 'name'; }; - $modelClass = get_class($model); + $modelClass = \get_class($model); - /** @var ObjectRepository|MockObject $repository */ + /** @var MockObject|ObjectRepository $repository */ $repository = $this->getMockByCalls(ObjectRepository::class, [ Call::create('findOneBy') ->with(['name' => 'name']) @@ -79,7 +79,7 @@ public function testWithSameExistingModel(): void Call::create('getIdentifier')->with()->willReturn(['id']), ]); - /** @var ObjectManager|MockObject $objectManager */ + /** @var MockObject|ObjectManager $objectManager */ $objectManager = $this->getMockByCalls(ObjectManager::class, [ Call::create('getRepository')->with($modelClass)->willReturn($repository), Call::create('getClassMetadata')->with($modelClass)->willReturn($classMetadata), @@ -102,9 +102,9 @@ public function testWithSameDifferentModel(): void private string $name = 'name'; }; - $modelClass = get_class($model); + $modelClass = \get_class($model); - /** @var ObjectRepository|MockObject $repository */ + /** @var MockObject|ObjectRepository $repository */ $repository = $this->getMockByCalls(ObjectRepository::class, [ Call::create('findOneBy') ->with(['name' => 'name']) @@ -116,7 +116,7 @@ public function testWithSameDifferentModel(): void Call::create('getIdentifier')->with()->willReturn(['id']), ]); - /** @var ObjectManager|MockObject $objectManager */ + /** @var MockObject|ObjectManager $objectManager */ $objectManager = $this->getMockByCalls(ObjectManager::class, [ Call::create('getRepository')->with($modelClass)->willReturn($repository), Call::create('getClassMetadata')->with($modelClass)->willReturn($classMetadata), @@ -135,7 +135,7 @@ public function testWithSameDifferentModel(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/EmailConstraintTest.php b/tests/Unit/Constraint/EmailConstraintTest.php index 794572a..46f71af 100644 --- a/tests/Unit/Constraint/EmailConstraintTest.php +++ b/tests/Unit/Constraint/EmailConstraintTest.php @@ -70,7 +70,7 @@ public function testWithInvalidEmail(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/FalseConstraintTest.php b/tests/Unit/Constraint/FalseConstraintTest.php index f00a92c..15b94e8 100644 --- a/tests/Unit/Constraint/FalseConstraintTest.php +++ b/tests/Unit/Constraint/FalseConstraintTest.php @@ -90,7 +90,7 @@ public function testWithStdClass(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/MapConstraintTest.php b/tests/Unit/Constraint/MapConstraintTest.php index e666600..87a6788 100644 --- a/tests/Unit/Constraint/MapConstraintTest.php +++ b/tests/Unit/Constraint/MapConstraintTest.php @@ -44,7 +44,8 @@ public function testWithMissingConstraint(): void self::assertEquals([ new Error( - 'map.name2', 'constraint.map.field.notallowed', + 'map.name2', + 'constraint.map.field.notallowed', ['field' => 'name2', 'allowedFields' => ['name']] ), ], $constraint->validate('map', ['name2' => 'example'], $this->getContext(), $this->getValidator())); @@ -95,7 +96,7 @@ public function testWithConstraintButWithoutArray(): void private function getValidator(): ValidatorInterface { - /* @var ValidatorInterface|MockObject $validator */ + // @var ValidatorInterface|MockObject $validator return $this->getMockByCalls(ValidatorInterface::class); } @@ -110,11 +111,11 @@ private function getConstraint(bool $error = false): ConstraintInterface $constraint->expects(self::any())->method('validate')->willReturnCallback( static function ( - string $path, - $value, - ValidatorContextInterface $context, - ValidatorInterface $validator = null - ) use ($error) { + string $path, + $value, + ValidatorContextInterface $context, + ?ValidatorInterface $validator = null + ) use ($error) { if (!$error) { return []; } @@ -128,7 +129,7 @@ static function ( private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/NotBlankConstraintTest.php b/tests/Unit/Constraint/NotBlankConstraintTest.php index d085c7f..5701954 100644 --- a/tests/Unit/Constraint/NotBlankConstraintTest.php +++ b/tests/Unit/Constraint/NotBlankConstraintTest.php @@ -80,7 +80,7 @@ public function testWithBlankStdClass(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/NotNullConstraintTest.php b/tests/Unit/Constraint/NotNullConstraintTest.php index ce86bda..8b8f12f 100644 --- a/tests/Unit/Constraint/NotNullConstraintTest.php +++ b/tests/Unit/Constraint/NotNullConstraintTest.php @@ -73,7 +73,7 @@ public function testWithStdClass(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/NullConstraintTest.php b/tests/Unit/Constraint/NullConstraintTest.php index 0fc5b07..fc2d592 100644 --- a/tests/Unit/Constraint/NullConstraintTest.php +++ b/tests/Unit/Constraint/NullConstraintTest.php @@ -83,7 +83,7 @@ public function testWithStdClass(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/NumericConstraintTest.php b/tests/Unit/Constraint/NumericConstraintTest.php index f8e5007..15b0d86 100644 --- a/tests/Unit/Constraint/NumericConstraintTest.php +++ b/tests/Unit/Constraint/NumericConstraintTest.php @@ -75,7 +75,7 @@ public function testWithoutNumericString(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/NumericRangeConstraintTest.php b/tests/Unit/Constraint/NumericRangeConstraintTest.php index 22656fe..946efc1 100644 --- a/tests/Unit/Constraint/NumericRangeConstraintTest.php +++ b/tests/Unit/Constraint/NumericRangeConstraintTest.php @@ -93,7 +93,7 @@ public function testWithMinAndMaxToManyValues(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/SortConstraintTest.php b/tests/Unit/Constraint/SortConstraintTest.php index 388f352..36d0080 100644 --- a/tests/Unit/Constraint/SortConstraintTest.php +++ b/tests/Unit/Constraint/SortConstraintTest.php @@ -22,7 +22,7 @@ final class SortConstraintTest extends TestCase public function testValidateWithString(): void { - /** @var ValidatorContextInterface|MockObject $context */ + /** @var MockObject|ValidatorContextInterface $context */ $context = $this->getMockByCalls(ValidatorContextInterface::class); $constraint = new SortConstraint(['name']); @@ -35,7 +35,7 @@ public function testValidateWithString(): void public function testValidateWithStdClass(): void { - /** @var ValidatorContextInterface|MockObject $context */ + /** @var MockObject|ValidatorContextInterface $context */ $context = $this->getMockByCalls(ValidatorContextInterface::class); $constraint = new SortConstraint(['name']); @@ -48,7 +48,7 @@ public function testValidateWithStdClass(): void public function testValidateWithUnsupportedFieldAndUnsupportedOrder(): void { - /** @var ValidatorContextInterface|MockObject $context */ + /** @var MockObject|ValidatorContextInterface $context */ $context = $this->getMockByCalls(ValidatorContextInterface::class); $constraint = new SortConstraint(['name']); @@ -72,7 +72,7 @@ public function testValidateWithUnsupportedFieldAndUnsupportedOrder(): void public function testValidateWithUnsupportedFieldAndUnsupportedOrderType(): void { - /** @var ValidatorContextInterface|MockObject $context */ + /** @var MockObject|ValidatorContextInterface $context */ $context = $this->getMockByCalls(ValidatorContextInterface::class); $constraint = new SortConstraint(['name']); @@ -106,7 +106,7 @@ public function testValidateWithUnsupportedFieldAndUnsupportedOrderType(): void public function testValidate(): void { - /** @var ValidatorContextInterface|MockObject $context */ + /** @var MockObject|ValidatorContextInterface $context */ $context = $this->getMockByCalls(ValidatorContextInterface::class); $constraint = new SortConstraint(['name']); diff --git a/tests/Unit/Constraint/Symfony/ConstraintAdapterTest.php b/tests/Unit/Constraint/Symfony/ConstraintAdapterTest.php index 9e68b89..92fd932 100644 --- a/tests/Unit/Constraint/Symfony/ConstraintAdapterTest.php +++ b/tests/Unit/Constraint/Symfony/ConstraintAdapterTest.php @@ -37,7 +37,7 @@ public function testValidate(): void $constraintAdapter = new ConstraintAdapter($constraint, $constraintValidator); - /** @var ValidatorContextInterface|MockObject $context */ + /** @var MockObject|ValidatorContextInterface $context */ $context = $this->getMockByCalls(ValidatorContextInterface::class); self::assertSame([], $constraintAdapter->validate('path[0].property', 'test', $context)); diff --git a/tests/Unit/Constraint/Symfony/ExecutionContextTest.php b/tests/Unit/Constraint/Symfony/ExecutionContextTest.php index 3096d85..d207797 100644 --- a/tests/Unit/Constraint/Symfony/ExecutionContextTest.php +++ b/tests/Unit/Constraint/Symfony/ExecutionContextTest.php @@ -262,7 +262,7 @@ public function testGetErrors(): void private function getContext(array $methods = []): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class, $methods); } } diff --git a/tests/Unit/Constraint/TrueConstraintTest.php b/tests/Unit/Constraint/TrueConstraintTest.php index db78d5e..31ebc2b 100644 --- a/tests/Unit/Constraint/TrueConstraintTest.php +++ b/tests/Unit/Constraint/TrueConstraintTest.php @@ -90,7 +90,7 @@ public function testWithStdClass(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/TypeConstraintTest.php b/tests/Unit/Constraint/TypeConstraintTest.php index 0cdecac..8abebd6 100644 --- a/tests/Unit/Constraint/TypeConstraintTest.php +++ b/tests/Unit/Constraint/TypeConstraintTest.php @@ -58,20 +58,20 @@ public function testWithDateTimeValueAgainstStdClass(): void 'stdClass', 'constraint.type.invalidtype', [ - 'type' => \DateTime::class, + 'type' => \DateTimeImmutable::class, 'wishedType' => \stdClass::class, ] ); self::assertEquals( [$error], - $constraint->validate('stdClass', new \DateTime('2004-02-12T15:19:21+00:00'), $this->getContext()) + $constraint->validate('stdClass', new \DateTimeImmutable('2004-02-12T15:19:21+00:00'), $this->getContext()) ); } private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } } diff --git a/tests/Unit/Constraint/ValidConstraintTest.php b/tests/Unit/Constraint/ValidConstraintTest.php index 7d17f89..20070a1 100644 --- a/tests/Unit/Constraint/ValidConstraintTest.php +++ b/tests/Unit/Constraint/ValidConstraintTest.php @@ -107,13 +107,13 @@ public function testWithStringValue(): void private function getContext(): ValidatorContextInterface { - /* @var ValidatorContextInterface|MockObject $context */ + // @var ValidatorContextInterface|MockObject $context return $this->getMockByCalls(ValidatorContextInterface::class); } private function getValidator(array $methods = []): ValidatorInterface { - /* @var ValidatorInterface|MockObject $validator */ + // @var ValidatorInterface|MockObject $validator return $this->getMockByCalls(ValidatorInterface::class, $methods); } diff --git a/tests/Unit/Error/ApiProblemErrorMessagesTest.php b/tests/Unit/Error/ApiProblemErrorMessagesTest.php index f6a71ab..d2d90aa 100644 --- a/tests/Unit/Error/ApiProblemErrorMessagesTest.php +++ b/tests/Unit/Error/ApiProblemErrorMessagesTest.php @@ -70,7 +70,7 @@ public function testWithMessages(): void private function getError(string $path, string $key, array $arguments = []): ErrorInterface { - /* @var ErrorInterface|MockObject $error */ + // @var ErrorInterface|MockObject $error return $this->getMockByCalls(ErrorInterface::class, [ Call::create('getPath')->with()->willReturn($path), Call::create('getKey')->with()->willReturn($key), diff --git a/tests/Unit/Error/ErrorMessagesTest.php b/tests/Unit/Error/ErrorMessagesTest.php index a3e758a..a243d00 100644 --- a/tests/Unit/Error/ErrorMessagesTest.php +++ b/tests/Unit/Error/ErrorMessagesTest.php @@ -59,7 +59,7 @@ public function testWithMessages(): void private function getError(string $path, string $key, array $arguments = []): ErrorInterface { - /* @var ErrorInterface|MockObject $error */ + // @var ErrorInterface|MockObject $error return $this->getMockByCalls(ErrorInterface::class, [ Call::create('getPath')->with()->willReturn($path), Call::create('getKey')->with()->willReturn($key), diff --git a/tests/Unit/Error/NestedErrorMessagesTest.php b/tests/Unit/Error/NestedErrorMessagesTest.php index a190ce5..2e5e14b 100644 --- a/tests/Unit/Error/NestedErrorMessagesTest.php +++ b/tests/Unit/Error/NestedErrorMessagesTest.php @@ -65,7 +65,7 @@ public function testWithMessages(): void private function getError(string $path, string $key, array $arguments = []): ErrorInterface { - /* @var ErrorInterface|MockObject $error */ + // @var ErrorInterface|MockObject $error return $this->getMockByCalls(ErrorInterface::class, [ Call::create('getPath')->with()->willReturn($path), Call::create('getKey')->with()->willReturn($key), diff --git a/tests/Unit/Mapping/LazyValidationMappingProviderTest.php b/tests/Unit/Mapping/LazyValidationMappingProviderTest.php index 90c683c..a245d41 100644 --- a/tests/Unit/Mapping/LazyValidationMappingProviderTest.php +++ b/tests/Unit/Mapping/LazyValidationMappingProviderTest.php @@ -60,10 +60,10 @@ private function getContainer(array $services): ContainerInterface * @param ValidationPropertyMappingInterface[] $denormalizationPropertyMappings */ private function getValidationObjectMapping( - ValidationClassMappingInterface $denormalizationClassMapping = null, + ?ValidationClassMappingInterface $denormalizationClassMapping, array $denormalizationPropertyMappings ): ValidationMappingProviderInterface { - /* @var ValidationMappingProviderInterface|MockObject $mapping */ + // @var ValidationMappingProviderInterface|MockObject $mapping return $this->getMockByCalls(ValidationMappingProviderInterface::class, [ Call::create('getValidationClassMapping')->with('path')->willReturn($denormalizationClassMapping), Call::create('getValidationPropertyMappings')->with('path')->willReturn($denormalizationPropertyMappings), @@ -71,7 +71,7 @@ private function getValidationObjectMapping( } /** - * @return ValidationClassMappingInterface|MockObject + * @return MockObject|ValidationClassMappingInterface */ private function getValidationClassMapping(): ValidationClassMappingInterface { @@ -79,7 +79,7 @@ private function getValidationClassMapping(): ValidationClassMappingInterface } /** - * @return ValidationPropertyMappingInterface|MockObject + * @return MockObject|ValidationPropertyMappingInterface */ private function getValidationPropertyMapping(): ValidationPropertyMappingInterface { diff --git a/tests/Unit/Mapping/ValidationClassMappingBuilderTest.php b/tests/Unit/Mapping/ValidationClassMappingBuilderTest.php index a1fcaf5..d8ea613 100644 --- a/tests/Unit/Mapping/ValidationClassMappingBuilderTest.php +++ b/tests/Unit/Mapping/ValidationClassMappingBuilderTest.php @@ -42,7 +42,7 @@ public function testGetMapping(): void private function getConstraint(): ConstraintInterface { - /* @var ConstraintInterface|MockObject $constraint */ + // @var ConstraintInterface|MockObject $constraint return $this->getMockByCalls(ConstraintInterface::class); } } diff --git a/tests/Unit/Mapping/ValidationClassMappingTest.php b/tests/Unit/Mapping/ValidationClassMappingTest.php index 71859ac..ef5078a 100644 --- a/tests/Unit/Mapping/ValidationClassMappingTest.php +++ b/tests/Unit/Mapping/ValidationClassMappingTest.php @@ -39,7 +39,7 @@ public function testGetGroups(): void private function getConstraint(): ConstraintInterface { - /* @var ConstraintInterface|MockObject $constraint */ + // @var ConstraintInterface|MockObject $constraint return $this->getMockByCalls(ConstraintInterface::class); } } diff --git a/tests/Unit/Mapping/ValidationMappingProviderRegistryTest.php b/tests/Unit/Mapping/ValidationMappingProviderRegistryTest.php index e349038..7ab56dd 100644 --- a/tests/Unit/Mapping/ValidationMappingProviderRegistryTest.php +++ b/tests/Unit/Mapping/ValidationMappingProviderRegistryTest.php @@ -26,7 +26,7 @@ public function testGetObjectMapping(): void $this->getValidationObjectMapping(), ]); - $mapping = $registry->provideMapping(get_class($object)); + $mapping = $registry->provideMapping(\get_class($object)); self::assertInstanceOf(ValidationMappingProviderInterface::class, $mapping); } @@ -38,7 +38,7 @@ public function testGetMissingObjectMapping(): void $registry = new ValidationMappingProviderRegistry([]); - $registry->provideMapping(get_class(new \stdClass())); + $registry->provideMapping(\get_class(new \stdClass())); } public function testGetObjectMappingFromDoctrineProxy(): void @@ -49,14 +49,14 @@ public function testGetObjectMappingFromDoctrineProxy(): void $this->getValidationProxyObjectMapping(), ]); - $mapping = $registry->provideMapping(get_class($object)); + $mapping = $registry->provideMapping(\get_class($object)); self::assertInstanceOf(ValidationMappingProviderInterface::class, $mapping); } private function getValidationObjectMapping(): ValidationMappingProviderInterface { - /** @var ValidationMappingProviderInterface|MockObject $objectMapping */ + /** @var MockObject|ValidationMappingProviderInterface $objectMapping */ $objectMapping = $this->getMockBuilder(ValidationMappingProviderInterface::class) ->setMethods([]) ->getMockForAbstractClass() @@ -65,7 +65,7 @@ private function getValidationObjectMapping(): ValidationMappingProviderInterfac $object = $this->getObject(); $objectMapping->expects(self::any())->method('getClass')->willReturnCallback( - static fn () => get_class($object) + static fn () => \get_class($object) ); return $objectMapping; @@ -73,7 +73,7 @@ private function getValidationObjectMapping(): ValidationMappingProviderInterfac private function getValidationProxyObjectMapping(): ValidationMappingProviderInterface { - /** @var ValidationMappingProviderInterface|MockObject $objectMapping */ + /** @var MockObject|ValidationMappingProviderInterface $objectMapping */ $objectMapping = $this->getMockBuilder(ValidationMappingProviderInterface::class) ->setMethods([]) ->getMockForAbstractClass() @@ -97,7 +97,7 @@ private function getObject() private ?string $name = null; /** - * @return string|null + * @return null|string */ public function getName() { diff --git a/tests/Unit/Mapping/ValidationPropertyMappingBuilderTest.php b/tests/Unit/Mapping/ValidationPropertyMappingBuilderTest.php index f47b26a..fed1ae3 100644 --- a/tests/Unit/Mapping/ValidationPropertyMappingBuilderTest.php +++ b/tests/Unit/Mapping/ValidationPropertyMappingBuilderTest.php @@ -50,13 +50,13 @@ public function testGetMapping(): void private function getConstraint(): ConstraintInterface { - /* @var ConstraintInterface|MockObject $constraint */ + // @var ConstraintInterface|MockObject $constraint return $this->getMockByCalls(ConstraintInterface::class); } private function getAccessor(): AccessorInterface { - /* @var AccessorInterface|MockObject $accessor */ + // @var AccessorInterface|MockObject $accessor return $this->getMockByCalls(AccessorInterface::class); } } diff --git a/tests/Unit/Mapping/ValidationPropertyMappingTest.php b/tests/Unit/Mapping/ValidationPropertyMappingTest.php index 93b0be2..f2123d9 100644 --- a/tests/Unit/Mapping/ValidationPropertyMappingTest.php +++ b/tests/Unit/Mapping/ValidationPropertyMappingTest.php @@ -62,13 +62,13 @@ public function testGetAccessor(): void private function getConstraint(): ConstraintInterface { - /* @var ConstraintInterface|MockObject $constraint */ + // @var ConstraintInterface|MockObject $constraint return $this->getMockByCalls(ConstraintInterface::class); } private function getAccessor(): AccessorInterface { - /* @var AccessorInterface|MockObject $accessor */ + // @var AccessorInterface|MockObject $accessor return $this->getMockByCalls(AccessorInterface::class); } } diff --git a/tests/Unit/ValidatorTest.php b/tests/Unit/ValidatorTest.php index d7d332f..c3b93f0 100644 --- a/tests/Unit/ValidatorTest.php +++ b/tests/Unit/ValidatorTest.php @@ -32,7 +32,7 @@ final class ValidatorTest extends TestCase public function testValidateMissingMappingExpectValidatorLogicException(): void { $model = $this->getModel(); - $class = get_class($model); + $class = \get_class($model); $exceptionMessage = sprintf('There is no mapping for class: "%s"', $class); @@ -58,7 +58,7 @@ public function testValidateMissingMappingExpectValidatorLogicException(): void public function testValidateWithoutClassMappingAndWithoutPropertyMapping(): void { $model = $this->getModel(); - $class = get_class($model); + $class = \get_class($model); /** @var ValidationMappingProviderInterface $mapping */ $mapping = $this->getMockByCalls(ValidationMappingProviderInterface::class, [ @@ -82,7 +82,7 @@ public function testValidateWithoutClassMappingAndWithoutPropertyMapping(): void public function testValidateWithClassMappingAndWithPropertyMapping(): void { $model = $this->getModel(); - $class = get_class($model); + $class = \get_class($model); /** @var ErrorInterface $classError */ $classError = $this->getMockByCalls(ErrorInterface::class, [ @@ -153,26 +153,26 @@ public function testValidateWithClassMappingAndWithPropertyMapping(): void Call::create('info')->with('validate: path {path}', ['path' => '']), Call::create('debug')->with( 'validate: path {path}, constraint {constraint}', - ['path' => '', 'constraint' => get_class($classConstraint)] + ['path' => '', 'constraint' => \get_class($classConstraint)] ), Call::create('notice')->with( 'validate: path {path}, constraint {constraint}, error {error}', [ 'path' => '', - 'constraint' => get_class($classConstraint), + 'constraint' => \get_class($classConstraint), 'error' => ['key' => 'key', 'arguments' => ['key' => 'value']], ] ), Call::create('info')->with('validate: path {path}', ['path' => 'name']), Call::create('debug')->with( 'validate: path {path}, constraint {constraint}', - ['path' => 'name', 'constraint' => get_class($propertyConstraint)] + ['path' => 'name', 'constraint' => \get_class($propertyConstraint)] ), Call::create('notice')->with( 'validate: path {path}, constraint {constraint}, error {error}', [ 'path' => 'name', - 'constraint' => get_class($propertyConstraint), + 'constraint' => \get_class($propertyConstraint), 'error' => ['key' => 'key', 'arguments' => ['key' => 'value']], ] ), @@ -191,7 +191,7 @@ public function testValidateWithClassMappingAndWithPropertyMapping(): void public function testValidateWithClassMappingAndWithPropertyMappingWithoutUsedGroup(): void { $model = $this->getModel(); - $class = get_class($model); + $class = \get_class($model); /** @var ValidationClassMappingInterface $classMapping */ $classMapping = $this->getMockByCalls(ValidationClassMappingInterface::class, [ @@ -230,7 +230,7 @@ public function testValidateWithClassMappingAndWithPropertyMappingWithoutUsedGro public function testValidateWithClassMappingAndWithPropertyMappingWithUsedGroup(): void { $model = $this->getModel(); - $class = get_class($model); + $class = \get_class($model); /** @var ErrorInterface $classError */ $classError = $this->getMockByCalls(ErrorInterface::class, [ @@ -303,26 +303,26 @@ public function testValidateWithClassMappingAndWithPropertyMappingWithUsedGroup( Call::create('info')->with('validate: path {path}', ['path' => '']), Call::create('debug')->with( 'validate: path {path}, constraint {constraint}', - ['path' => '', 'constraint' => get_class($classConstraint)] + ['path' => '', 'constraint' => \get_class($classConstraint)] ), Call::create('notice')->with( 'validate: path {path}, constraint {constraint}, error {error}', [ 'path' => '', - 'constraint' => get_class($classConstraint), + 'constraint' => \get_class($classConstraint), 'error' => ['key' => 'key', 'arguments' => ['key' => 'value']], ] ), Call::create('info')->with('validate: path {path}', ['path' => 'name']), Call::create('debug')->with( 'validate: path {path}, constraint {constraint}', - ['path' => 'name', 'constraint' => get_class($propertyConstraint)] + ['path' => 'name', 'constraint' => \get_class($propertyConstraint)] ), Call::create('notice')->with( 'validate: path {path}, constraint {constraint}, error {error}', [ 'path' => 'name', - 'constraint' => get_class($propertyConstraint), + 'constraint' => \get_class($propertyConstraint), 'error' => ['key' => 'key', 'arguments' => ['key' => 'value']], ] ),