Final Class Yiisoft\Yii\Gii\Validator\ReservedKeywordHandler
| Inheritance | Yiisoft\Yii\Gii\Validator\ReservedKeywordHandler |
|---|---|
| Implements | Yiisoft\Validator\RuleHandlerInterface |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| validate() | Yiisoft\Yii\Gii\Validator\ReservedKeywordHandler |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| KEYWORDS | [ '__class__', '__dir__', '__file__', '__function__', '__line__', '__method__', '__namespace__', '__trait__', 'abstract', 'and', 'array', 'as', 'break', 'case', 'catch', 'callable', 'cfunction', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exception', 'exit', 'extends', 'final', 'finally', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'old_function', 'or', 'parent', 'php_user_filter', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'this', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor', 'fn', ] | Yiisoft\Yii\Gii\Validator\ReservedKeywordHandler |
Method Details
| public validate( mixed $value, object $rule, \Yiisoft\Validator\ValidationContext $context ): \Yiisoft\Validator\Result | ||
| $value | mixed | |
| $rule | object | |
| $context | \Yiisoft\Validator\ValidationContext | |
public function validate(mixed $value, object $rule, ValidationContext $context): Result
{
if (!$rule instanceof ReservedKeywordRule) {
throw new UnexpectedRuleException(ReservedKeywordRule::class, $rule);
}
$result = new Result();
if (!is_string($value)) {
$result->addError(sprintf('Value must be a string, %s given.".', gettype($value)));
return $result;
}
if (self::isReservedKeyword($value)) {
$result->addError(
message: 'The value {value} is reserved keyword.',
parameters: ['value' => $value],
);
}
return $result;
}
Signup or Login in order to comment.