3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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()) { $length = mb_strlen($value, '8bit'); // Empty if (false === ($options['empty'] ?? true)) { if (0 === $length) { throw new LengthException('chaine vide !'); } } // Min & max length if ($options['max']) { $maxLength = IntFilter::check($options['max'], ['min' => 1]); if ($length > $maxLength) { throw new LengthException('trop long !'); } } if ($options['min']) { $minLength = IntFilter::check($options['min'], ['min' => 1]); if ($length > $minLength) { throw new LengthException('trop court !'); } } return $value; } } var_dump(StringFilter::check('test '));
based on GX61B
Output for 7.0.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/CRhQW on line 14
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Declaration of IntFilter::check() must be compatible with that of Filter::check() in /in/CRhQW:8 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Strict Standards: Static function Filter::check() should not be abstract in /in/CRhQW on line 5 Fatal error: Declaration of IntFilter::check() must be compatible with Filter::check($value, array $options = Array) in /in/CRhQW on line 14
Process exited with code 255.