- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.6
- Fatal error: Declaration of IntFilter::check(string $value, array $options = Array) must be compatible with Filter::check($value, array $options = Array) in /in/0AgY0 on line 14
Process exited with code 255.
<?php
abstract class Filter
{
abstract public static function check($value, array $options = array());
}
final class IntFilter extends Filter
{
public static function check(string $value, array $options = array())
{
return $value;
}
}
final class StringFilter extends Filter
{
public static function check(string $value, array $options = array())
{
// Trim
if (false !== ($options['trim'] ?? true)) {
$value = trim($value);
}
$length = mb_strlen($value, '8bit');
// Empty
if (false === ($options['empty'] ?? true)) {
if (0 === $length) {
throw new LengthException('chaine vide !');
}
}
// Min & max length
if (isset($options['max'])) {
$maxLength = IntFilter::check($options['max'], ['min' => 1]);
if ($length > $maxLength) {
throw new LengthException('trop long !');
}
}
if (isset($options['min'])) {
$minLength = IntFilter::check($options['min'], ['min' => 1]);
if ($length > $minLength) {
throw new LengthException('trop court !');
}
}
return $value;
}
}
var_dump(StringFilter::check('test '));