Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Not an Issue
-
Affects Version/s: 1.7.1, 1.7.3
-
Fix Version/s: 1.7.8
-
Component/s: Zend_Validate
-
Labels:None
Description
Zend_Validate::is($value, 'InArray', array(1,2,3)) gives the following error (the array dump is the output of a print_r($args) just before $object = $class->newInstanceArgs($args); on line 153 of Zend/Validate.php):
Array
(
[0] => 1
[1] => 2
[2] => 3
)
<br />
<b>Catchable fatal error</b>: Argument 1 passed to Zend_Validate_InArray::__construct() must be an array
, integer given in <b>/path/to/library/Zend/Validate/InArray.php
</b> on line <b>69</b><br />
After temporarly removing the array type hinting from line 69 of Zend/Validate/InArray.php i dumped the $haystack parameter and got "(int) 1" (the first element) as the output.
PHP is 5.2.4 on Linux. (a friend also reproduced the issue on PHP 5.2.6)
The is method expects all options to be given concated as array...
This means when the validator expects $min, $max you would have to give "array($min, $max);
But as the array validator accepts only ONE option, and you gave three, the notation you gave is not correct.
To give an array as input you will have to give:
because your notation said
Zend_Validate_InArray(1, 2, 3);
which can not work for the InArray validator.