ValidatorMissingRequiredOptionRule
API reference › PHPStan › rules › ValidatorMissingRequiredOptionRule
Reports model validation rules that create RangeValidator, RegularExpressionValidator or
FilterValidator without the range, pattern or filter option, whose absence or null value makes the
validator’s init() throw an InvalidConfigException.
Only these exact classes are checked; subclasses stand aside. A container definition that sets the option, an option
whose type may be non-null, and any other option that isn’t an on ... event or a plain public property, such as
an as ... behavior or an unknown name that Yii rejects first, make the rule stand aside.
ValidatorConfigurationResolver for the dispatch, including the declared alias table assumption.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Initializes static class reflection and the analysis service map. | ValidatorMissingRequiredOptionRule |
getNodeType() | Returns the node class this rule analyses. | ValidatorMissingRequiredOptionRule |
processNode() | Returns one diagnostic per rule whose validator lacks its required option. | ValidatorMissingRequiredOptionRule |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)Initializes static class reflection and the analysis service map.
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionProvider | PHPStan\ | |
$serviceMap | yii2\ |
getNodeType()
Section titled “getNodeType() ”public function getNodeType(): class-string<PhpParser\Node\Stmt\Return_>Returns the node class this rule analyses.
Returns
class-string<PhpParser\Node\Stmt\Return_>
processNode()
Section titled “processNode() ”public function processNode(PhpParser\Node\Stmt\Return_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<PHPStan\Rules\IdentifierRuleError>Returns one diagnostic per rule whose validator lacks its required option.
Parameters
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Return statement to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
list<PHPStan\Rules\IdentifierRuleError>: Errors at each rule’s line.