44
55namespace Attributes \Validation ;
66
7- use ArrayAccess ;
7+ use ArrayObject ;
88use Attributes \Options ;
99use Attributes \Options \Exceptions \InvalidOptionException ;
1010use Attributes \Validation \Exceptions \ContextPropertyException ;
@@ -52,7 +52,7 @@ public function __construct(?PropertyValidator $validator = null, bool $stopFirs
5252 /**
5353 * Validates a given data according to a given model
5454 *
55- * @param array|ArrayAccess $data - Data to validate
55+ * @param array|ArrayObject $data - Data to validate
5656 * @param string|object $model - Model to validate against
5757 * @return object - Model populated with the validated data
5858 *
@@ -61,7 +61,7 @@ public function __construct(?PropertyValidator $validator = null, bool $stopFirs
6161 * @throws ReflectionException
6262 * @throws InvalidOptionException
6363 */
64- public function validate (array |ArrayAccess $ data , string |object $ model ): object
64+ public function validate (array |ArrayObject $ data , string |object $ model ): object
6565 {
6666 $ currentLevel = $ this ->context ->getOptional ('internal.recursionLevel ' , 0 );
6767 $ maxRecursionLevel = $ this ->context ->getOptional ('internal.maxRecursionLevel ' , 30 );
@@ -87,7 +87,7 @@ public function validate(array|ArrayAccess $data, string|object $model): object
8787 $ aliasName = $ this ->getAliasName ($ reflectionProperty , $ defaultAliasGenerator );
8888 $ this ->context ->push ('internal.currentProperty ' , $ propertyName );
8989
90- if (! array_key_exists ($ aliasName , $ data )) {
90+ if (! array_key_exists ($ aliasName , ( array ) $ data )) {
9191 if (! $ reflectionProperty ->isInitialized ($ validModel )) {
9292 try {
9393 $ errorInfo ->addError ("Missing required property ' $ aliasName' " );
@@ -128,7 +128,7 @@ public function validate(array|ArrayAccess $data, string|object $model): object
128128 /**
129129 * Validates a given data according to a given model
130130 *
131- * @param array|ArrayAccess $data - Data to validate
131+ * @param array|ArrayObject $data - Data to validate
132132 * @param callable $call - Callable to validate data against
133133 * @return array - Returns an array with the necessary arguments for the callable
134134 *
@@ -137,7 +137,7 @@ public function validate(array|ArrayAccess $data, string|object $model): object
137137 * @throws ReflectionException
138138 * @throws InvalidOptionException
139139 */
140- public function validateCallable (array |ArrayAccess $ data , callable $ call ): array
140+ public function validateCallable (array |ArrayObject $ data , callable $ call ): array
141141 {
142142 $ arguments = [];
143143 $ reflectionFunction = new ReflectionFunction ($ call );
@@ -153,7 +153,7 @@ public function validateCallable(array|ArrayAccess $data, callable $call): array
153153 $ aliasName = $ this ->getAliasName ($ parameter , $ defaultAliasGenerator );
154154 $ this ->context ->push ('internal.currentProperty ' , $ propertyName );
155155
156- if (! array_key_exists ($ aliasName , $ data ) && ! array_key_exists ($ index , $ data )) {
156+ if (! array_key_exists ($ aliasName , ( array ) $ data ) && ! array_key_exists ($ index , ( array ) $ data )) {
157157 if (! $ parameter ->isDefaultValueAvailable ()) {
158158 try {
159159 $ errorInfo ->addError ("Missing required argument ' $ aliasName' " );
0 commit comments