mirror of
https://github.com/Respect/Validation.git
synced 2024-06-07 16:22:16 +02:00
Only define filter_var options when it is valid
The third argument of "filter_var" must be either an integer or an array. On PHP 8 this "FilterVar" rule fails because we always pass that argument, even if it is null. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
2fad28b36b
commit
e0c6f33c01
|
@ -16,6 +16,8 @@ namespace Respect\Validation\Rules;
|
|||
use Respect\Validation\Exceptions\ComponentException;
|
||||
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_int;
|
||||
|
||||
use const FILTER_VALIDATE_BOOLEAN;
|
||||
use const FILTER_VALIDATE_DOMAIN;
|
||||
|
@ -57,6 +59,11 @@ final class FilterVar extends AbstractEnvelope
|
|||
throw new ComponentException('Cannot accept the given filter');
|
||||
}
|
||||
|
||||
parent::__construct(new Callback('filter_var', $filter, $options));
|
||||
$arguments = [$filter];
|
||||
if (is_array($options) || is_int($options)) {
|
||||
$arguments[] = $options;
|
||||
}
|
||||
|
||||
parent::__construct(new Callback('filter_var', ...$arguments));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue