diff --git a/composer.lock b/composer.lock index 40fc391..ccadc86 100644 --- a/composer.lock +++ b/composer.lock @@ -105,16 +105,16 @@ }, { "name": "respect/validation", - "version": "2.4.3", + "version": "2.4.4", "source": { "type": "git", "url": "https://github.com/Respect/Validation.git", - "reference": "7f4b3b3ec3ccdf330dfc4567bb43698018f3562a" + "reference": "f13f10f19978aea33af2a102a2f58f2db1e63619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Respect/Validation/zipball/7f4b3b3ec3ccdf330dfc4567bb43698018f3562a", - "reference": "7f4b3b3ec3ccdf330dfc4567bb43698018f3562a", + "url": "https://api.github.com/repos/Respect/Validation/zipball/f13f10f19978aea33af2a102a2f58f2db1e63619", + "reference": "f13f10f19978aea33af2a102a2f58f2db1e63619", "shasum": "" }, "require": { @@ -167,9 +167,9 @@ ], "support": { "issues": "https://github.com/Respect/Validation/issues", - "source": "https://github.com/Respect/Validation/tree/2.4.3" + "source": "https://github.com/Respect/Validation/tree/2.4.4" }, - "time": "2025-05-14T12:14:59+00:00" + "time": "2025-06-07T00:07:21+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -810,16 +810,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.13.1", + "version": "1.13.3", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c" + "reference": "faed855a7b5f4d4637717c2b3863e277116beb36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/1720ddd719e16cf0db4eb1c6eca108031636d46c", - "reference": "1720ddd719e16cf0db4eb1c6eca108031636d46c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/faed855a7b5f4d4637717c2b3863e277116beb36", + "reference": "faed855a7b5f4d4637717c2b3863e277116beb36", "shasum": "" }, "require": { @@ -858,7 +858,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.13.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.3" }, "funding": [ { @@ -866,7 +866,7 @@ "type": "tidelift" } ], - "time": "2025-04-29T12:36:36+00:00" + "time": "2025-07-05T12:25:42+00:00" }, { "name": "nikic/php-parser", @@ -1801,16 +1801,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68" + "reference": "b9e61a61e39e02dd90944e9115241c7f7e76bfd8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/b9e61a61e39e02dd90944e9115241c7f7e76bfd8", + "reference": "b9e61a61e39e02dd90944e9115241c7f7e76bfd8", "shasum": "" }, "require": { @@ -1842,9 +1842,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/2.1.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/2.2.0" }, - "time": "2025-02-19T13:28:12+00:00" + "time": "2025-07-13T07:04:09+00:00" }, { "name": "phpunit/php-code-coverage", @@ -3402,16 +3402,16 @@ }, { "name": "symfony/console", - "version": "v6.4.22", + "version": "v6.4.23", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "7d29659bc3c9d8e9a34e2c3414ef9e9e003e6cf3" + "reference": "9056771b8eca08d026cd3280deeec3cfd99c4d93" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/7d29659bc3c9d8e9a34e2c3414ef9e9e003e6cf3", - "reference": "7d29659bc3c9d8e9a34e2c3414ef9e9e003e6cf3", + "url": "https://api.github.com/repos/symfony/console/zipball/9056771b8eca08d026cd3280deeec3cfd99c4d93", + "reference": "9056771b8eca08d026cd3280deeec3cfd99c4d93", "shasum": "" }, "require": { @@ -3476,7 +3476,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.22" + "source": "https://github.com/symfony/console/tree/v6.4.23" }, "funding": [ { @@ -3492,7 +3492,7 @@ "type": "tidelift" } ], - "time": "2025-05-07T07:05:04+00:00" + "time": "2025-06-27T19:37:22+00:00" }, { "name": "symfony/deprecation-contracts", diff --git a/src/Validatable.php b/src/Validatable.php index cbe57d2..0e42e98 100644 --- a/src/Validatable.php +++ b/src/Validatable.php @@ -8,26 +8,26 @@ namespace Attributes\Validation; -use ArrayAccess; +use ArrayObject; use Attributes\Validation\Exceptions\ValidationException; interface Validatable { /** - * @param array|ArrayAccess $data - Data to be validated + * @param array|ArrayObject $data - Data to be validated * @param object $model - Model to validate against * * @throws ValidationException - If the validation fails */ - public function validate(array|ArrayAccess $data, object $model): object; + public function validate(array|ArrayObject $data, object $model): object; /** - * @param array|ArrayAccess $data - Data to be validated + * @param array|ArrayObject $data - Data to be validated * @param callable $call - Callable to be validated * * @returns array - Arguments in a sequence order for the given function * * @throws ValidationException - If the validation fails */ - public function validateCallable(array|ArrayAccess $data, callable $call): array; + public function validateCallable(array|ArrayObject $data, callable $call): array; } diff --git a/src/Validator.php b/src/Validator.php index 5b673da..1425c99 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -4,7 +4,7 @@ namespace Attributes\Validation; -use ArrayAccess; +use ArrayObject; use Attributes\Options; use Attributes\Options\Exceptions\InvalidOptionException; use Attributes\Validation\Exceptions\ContextPropertyException; @@ -52,7 +52,7 @@ public function __construct(?PropertyValidator $validator = null, bool $stopFirs /** * Validates a given data according to a given model * - * @param array|ArrayAccess $data - Data to validate + * @param array|ArrayObject $data - Data to validate * @param string|object $model - Model to validate against * @return object - Model populated with the validated data * @@ -61,7 +61,7 @@ public function __construct(?PropertyValidator $validator = null, bool $stopFirs * @throws ReflectionException * @throws InvalidOptionException */ - public function validate(array|ArrayAccess $data, string|object $model): object + public function validate(array|ArrayObject $data, string|object $model): object { $currentLevel = $this->context->getOptional('internal.recursionLevel', 0); $maxRecursionLevel = $this->context->getOptional('internal.maxRecursionLevel', 30); @@ -87,7 +87,7 @@ public function validate(array|ArrayAccess $data, string|object $model): object $aliasName = $this->getAliasName($reflectionProperty, $defaultAliasGenerator); $this->context->push('internal.currentProperty', $propertyName); - if (! array_key_exists($aliasName, $data)) { + if (! array_key_exists($aliasName, (array) $data)) { if (! $reflectionProperty->isInitialized($validModel)) { try { $errorInfo->addError("Missing required property '$aliasName'"); @@ -128,7 +128,7 @@ public function validate(array|ArrayAccess $data, string|object $model): object /** * Validates a given data according to a given model * - * @param array|ArrayAccess $data - Data to validate + * @param array|ArrayObject $data - Data to validate * @param callable $call - Callable to validate data against * @return array - Returns an array with the necessary arguments for the callable * @@ -137,7 +137,7 @@ public function validate(array|ArrayAccess $data, string|object $model): object * @throws ReflectionException * @throws InvalidOptionException */ - public function validateCallable(array|ArrayAccess $data, callable $call): array + public function validateCallable(array|ArrayObject $data, callable $call): array { $arguments = []; $reflectionFunction = new ReflectionFunction($call); @@ -153,7 +153,7 @@ public function validateCallable(array|ArrayAccess $data, callable $call): array $aliasName = $this->getAliasName($parameter, $defaultAliasGenerator); $this->context->push('internal.currentProperty', $propertyName); - if (! array_key_exists($aliasName, $data) && ! array_key_exists($index, $data)) { + if (! array_key_exists($aliasName, (array) $data) && ! array_key_exists($index, (array) $data)) { if (! $parameter->isDefaultValueAvailable()) { try { $errorInfo->addError("Missing required argument '$aliasName'");