Skip to content
PHP Ecosystem
Explore

ValidatorConfigurationResolver

API reference › PHPStan › rules › ValidatorConfigurationResolver

final readonly classyii2\extensions\phpstan\rules\ValidatorConfigurationResolver
Sourcesrc/rules/ValidatorConfigurationResolver.php

Resolves the validator class and options that Validator::createValidator() passes to Yii::createObject() for a Model::rules() entry using a closure, a qualified class name or one of Yii’s declared built-in aliases.

Assumes the declared alias table has not been changed at runtime. Method names, other unqualified names, qualified names under an overridden hasMethod() and incomplete or uncertain rules stand aside. Container definitions and the created class follow CreateObjectConfigurationResolver::resolveTypeOptions().

MethodDescriptionDefined by
__construct()Initializes static class reflection and the analysis service map.ValidatorConfigurationResolver
resolve()Returns the configuration of the validator that Yii creates for the rule, or null when it isn’t proven.ValidatorConfigurationResolver
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 resolve(PHPStan\Reflection\ClassReflection $owner, PHPStan\Type\Type $rule, int $line, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): yii2\extensions\phpstan\rules\ValidatorConfiguration|null

Returns the configuration of the validator that Yii creates for the rule, or null when it isn’t proven.

Records the declaration and source file dependencies of Validator before reading its declared alias table, and the dependencies of CreateObjectConfigurationResolver::resolveTypeOptions().

Parameters

ParameterTypeDescription
$ownerPHPStan\Reflection\ClassReflectionModel whose rules() returns the rule.
$rulePHPStan\Type\TypeNative type of the rule.
$lineintLine reported for the rule’s options.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

ValidatorConfiguration|null