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()) { // 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 '));
based on RGEcp
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/0AgY0 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/0AgY0: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/0AgY0 on line 5 Fatal error: Declaration of IntFilter::check() must be compatible with Filter::check($value, array $options = Array) in /in/0AgY0 on line 14
Process exited with code 255.