Skip to content
PHP Ecosystem
Explore

ValidatorMissingRequiredOptionRule

API reference › PHPStan › rules › ValidatorMissingRequiredOptionRule

final readonly classyii2\extensions\phpstan\rules\ValidatorMissingRequiredOptionRule
ImplementsRule
Sourcesrc/rules/ValidatorMissingRequiredOptionRule.php

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.

MethodDescriptionDefined 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
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)

Initializes static class reflection and the analysis service map.

Parameters

ParameterTypeDescription
$reflectionProviderPHPStan\Reflection\ReflectionProvider
$serviceMapyii2\extensions\phpstan\ServiceMap
public function getNodeType(): class-string<PhpParser\Node\Stmt\Return_>

Returns the node class this rule analyses.

Returns

class-string<PhpParser\Node\Stmt\Return_>

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

ParameterTypeDescription
$nodePhpParser\Node\Stmt\Return_Return statement to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<PHPStan\Rules\IdentifierRuleError>: Errors at each rule’s line.