Skip to content
PHP Ecosystem
Explore

BehaviorDefinitionResolver

API reference › PHPStan › rules › BehaviorDefinitionResolver

final classyii2\extensions\phpstan\rules\BehaviorDefinitionResolver
Sourcesrc/rules/BehaviorDefinitionResolver.php

Finds behavior definitions that Component can’t attach, and behavior configuration options that the created Behavior can’t assign or whose value it never accepts, in behaviors() returns, attachBehavior() and attachBehaviors() arguments and as options of Yii::createObject() configurations.

A definition or option is reported only when Yii certainly fails on it; dynamic, uncertain or overridden paths stand aside. Options are classified by ObjectOptionAssignment::unknownOptions() and CreateObjectConfigurationResolver::rejectedOptions().

MethodDescriptionDefined by
__construct()Initializes the resolver with class reflection and the analysis configuration.BehaviorDefinitionResolver
resolveAttachCall()Returns the definitions of an attachBehavior() or attachBehaviors() call that can’t be attached.BehaviorDefinitionResolver
resolveAttachCallInvalidOptionTypes()Returns the options of the behavior configurations of an attachBehavior() or attachBehaviors() call whose value the created behavior never accepts, in definition and configuration order.BehaviorDefinitionResolver
resolveAttachCallUnknownOptions()Returns the options of the behavior configurations of an attachBehavior() or attachBehaviors() call that the created behavior can’t assign, in definition and configuration order.BehaviorDefinitionResolver
resolveBehaviorsReturn()Returns the definitions of a behaviors() return statement that can’t be attached.BehaviorDefinitionResolver
resolveBehaviorsReturnInvalidOptionTypes()Returns the options of the behavior configurations of a behaviors() return statement whose value the created behavior never accepts, in definition and configuration order.BehaviorDefinitionResolver
resolveBehaviorsReturnUnknownOptions()Returns the options of the behavior configurations of a behaviors() return statement that the created behavior can’t assign, in definition and configuration order.BehaviorDefinitionResolver
resolveCreateObjectAsInvalidOptionTypes()Returns the options of the behavior configurations in the as options of a Yii::createObject() call whose value the created behavior never accepts, in configuration order.BehaviorDefinitionResolver
resolveCreateObjectAsOptions()Returns the as options of a Yii::createObject() call that the created component rejects or can’t attach, in configuration order.BehaviorDefinitionResolver
resolveCreateObjectAsUnknownOptions()Returns the options of the behavior configurations in the as options of a Yii::createObject() call that the created behavior can’t assign, in configuration order.BehaviorDefinitionResolver
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)

Initializes the resolver with class reflection and the analysis configuration.

Parameters

ParameterTypeDescription
$reflectionProviderPHPStan\Reflection\ReflectionProviderProvides class reflection for owners and resolved classes.
$serviceMapyii2\extensions\phpstan\ServiceMapService and component map for Yii Application static analysis.
public function resolveAttachCall(PhpParser\Node\Expr\MethodCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\InvalidBehaviorDefinition>

Returns the definitions of an attachBehavior() or attachBehaviors() call that can’t be attached.

Records the construction:<id> value dependency and the class dependency of each resolved definition.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\MethodCallMethod call to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<InvalidBehaviorDefinition>

public function resolveAttachCallInvalidOptionTypes(PhpParser\Node\Expr\MethodCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\InvalidBehaviorOptionType>

Returns the options of the behavior configurations of an attachBehavior() or attachBehaviors() call whose value the created behavior never accepts, in definition and configuration order.

Records the dependencies of CreateObjectConfigurationResolver::resolveTypeOptions() and ObjectOptionAssignment::rejectingTarget() for each configuration.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\MethodCallMethod call to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<InvalidBehaviorOptionType>

public function resolveAttachCallUnknownOptions(PhpParser\Node\Expr\MethodCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\UnknownBehaviorOption>

Returns the options of the behavior configurations of an attachBehavior() or attachBehaviors() call that the created behavior can’t assign, in definition and configuration order.

Records the dependencies of CreateObjectConfigurationResolver::resolveTypeOptions() for each configuration.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\MethodCallMethod call to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<UnknownBehaviorOption>

public function resolveBehaviorsReturn(PhpParser\Node\Stmt\Return_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\InvalidBehaviorDefinition>

Returns the definitions of a behaviors() return statement that can’t be attached.

Records the declaration dependency of the owner, and the construction:<id> value dependency and the class dependency of each resolved definition.

Parameters

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

Returns

list<InvalidBehaviorDefinition>

resolveBehaviorsReturnInvalidOptionTypes()

Section titled “resolveBehaviorsReturnInvalidOptionTypes() ”
public function resolveBehaviorsReturnInvalidOptionTypes(PhpParser\Node\Stmt\Return_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\InvalidBehaviorOptionType>

Returns the options of the behavior configurations of a behaviors() return statement whose value the created behavior never accepts, in definition and configuration order.

Records the declaration dependency of the owner and the dependencies of CreateObjectConfigurationResolver::resolveTypeOptions() and ObjectOptionAssignment::rejectingTarget() for each configuration.

Parameters

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

Returns

list<InvalidBehaviorOptionType>

public function resolveBehaviorsReturnUnknownOptions(PhpParser\Node\Stmt\Return_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\UnknownBehaviorOption>

Returns the options of the behavior configurations of a behaviors() return statement that the created behavior can’t assign, in definition and configuration order.

Records the declaration dependency of the owner and the dependencies of CreateObjectConfigurationResolver::resolveTypeOptions() for each configuration.

Parameters

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

Returns

list<UnknownBehaviorOption>

resolveCreateObjectAsInvalidOptionTypes()

Section titled “resolveCreateObjectAsInvalidOptionTypes() ”
public function resolveCreateObjectAsInvalidOptionTypes(PhpParser\Node\Expr\StaticCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\InvalidBehaviorOptionType>

Returns the options of the behavior configurations in the as options of a Yii::createObject() call whose value the created behavior never accepts, in configuration order.

Reads the same configurations as resolveCreateObjectAsUnknownOptions(), and records the same dependencies and those of ObjectOptionAssignment::rejectingTarget().

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\StaticCallStatic call to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<InvalidBehaviorOptionType>

public function resolveCreateObjectAsOptions(PhpParser\Node\Expr\StaticCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\InvalidBehaviorAsDefinition>

Returns the as options of a Yii::createObject() call that the created component rejects or can’t attach, in configuration order.

Records the dependencies of CreateObjectConfigurationResolver::resolve(), the class dependency of each named class and, for an accepted class, the construction:<id> value dependency and the class dependency of its container result.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\StaticCallStatic call to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<InvalidBehaviorAsDefinition>

public function resolveCreateObjectAsUnknownOptions(PhpParser\Node\Expr\StaticCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<yii2\extensions\phpstan\rules\UnknownBehaviorOption>

Returns the options of the behavior configurations in the as options of a Yii::createObject() call that the created behavior can’t assign, in configuration order.

Only configurations whose class Component::__set() certainly accepts are read, since it checks the supplied class before Yii::createObject() assigns any option.

Records the dependencies of CreateObjectConfigurationResolver::resolve(), the class dependency of each accepted class and the dependencies of CreateObjectConfigurationResolver::resolveTypeOptions() for each configuration.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\StaticCallStatic call to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

list<UnknownBehaviorOption>