sRegExp = static::DEFAULT_REGEXP; parent::__construct($sErrorMessage); } public function Validate($value): array { if (is_null($value)) { $value = ''; // calling preg_match with null as subject is deprecated since PHP 8.1 } if (preg_match($this->GetRegExp(true), $value)) { return []; } return [$this->sErrorMessage]; } /** * Returns the regular expression of the validator. * * @param boolean $bWithSlashes If true, surrounds $sRegExp with '/'. Used with preg_match & co * * @return string */ public function GetRegExp($bWithSlashes = false) { if ($bWithSlashes) { $sRet = '/'.str_replace('/', '\\/', $this->sRegExp).'/'; } else { $sRet = $this->sRegExp; } return $sRet; } }