3v4l.org

run code in 300+ PHP versions simultaneously
<?php class YearIsValid implements ValidatorRuleInterface { private string $errorText; private int $minYear; private int $maxYear; public function __construct(int $minYear, int $maxYear) { $this->minYear = $minYear; $this->maxYear = $maxYear; $this->errorText = "Год рождения не может быть меньше $this->minYear и не может быть больше $this->maxYear."; } public function __invoke(mixed $value): ?ValidationError { if (!is_int($value)) { throw new TypeException("Неправильный тип данных в аргументе функции."); } $resultMin = $value < $minYear; $resultMax = $value > $maxYear; if ($resultMin || $resultMax) { return new ValidationError($this->errorText); } else { return null; } } }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
154.72 ms | 1619 KiB | 8 Q