BehaviorDefinitionResolver
API reference › PHPStan › rules › BehaviorDefinitionResolver
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().
Methods
Section titled “Methods”| Method | Description | Defined 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)Initializes the resolver with class reflection and the analysis configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionProvider | PHPStan\ | Provides class reflection for owners and resolved classes. |
$serviceMap | yii2\ | Service and component map for Yii Application static analysis. |
resolveAttachCall()
Section titled “resolveAttachCall() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Method call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
resolveAttachCallInvalidOptionTypes()
Section titled “resolveAttachCallInvalidOptionTypes() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Method call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
resolveAttachCallUnknownOptions()
Section titled “resolveAttachCallUnknownOptions() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Method call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
list<UnknownBehaviorOption>
resolveBehaviorsReturn()
Section titled “resolveBehaviorsReturn() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Return statement to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Return statement to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
resolveBehaviorsReturnUnknownOptions()
Section titled “resolveBehaviorsReturnUnknownOptions() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Return statement to inspect. |
$scope | PHPStan\ | Current 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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Static call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
resolveCreateObjectAsOptions()
Section titled “resolveCreateObjectAsOptions() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Static call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
resolveCreateObjectAsUnknownOptions()
Section titled “resolveCreateObjectAsUnknownOptions() ”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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Static call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
list<UnknownBehaviorOption>