Skip to content
PHP Ecosystem
Explore

AttachBehaviorInvalidDefinitionRule

API reference › PHPStan › rules › AttachBehaviorInvalidDefinitionRule

final classyii2\extensions\phpstan\rules\AttachBehaviorInvalidDefinitionRule
ImplementsRule
Sourcesrc/rules/AttachBehaviorInvalidDefinitionRule.php

Reports behavior definitions passed to Component::attachBehavior() or Component::attachBehaviors() that Yii can’t attach.

BehaviorDefinitionResolver for the definitions the rule reports and those it stands aside on.

MethodDescriptionDefined by
__construct()Initializes the rule with class reflection and the analysis configuration.AttachBehaviorInvalidDefinitionRule
getNodeType()Returns the node class this rule analyses.AttachBehaviorInvalidDefinitionRule
processNode()Returns one error per passed definition that Yii can’t attach.AttachBehaviorInvalidDefinitionRule
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)

Initializes the rule with class reflection and the analysis configuration.

Parameters

ParameterTypeDescription
$reflectionProviderPHPStan\Reflection\ReflectionProviderProvides class reflection for receivers and resolved classes.
$serviceMapyii2\extensions\phpstan\ServiceMapService and component map for Yii Application static analysis.
public function getNodeType(): class-string<PhpParser\Node\Expr\MethodCall>

Returns the node class this rule analyses.

Returns

class-string<PhpParser\Node\Expr\MethodCall>

public function processNode(PhpParser\Node\Expr\MethodCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<PHPStan\Rules\IdentifierRuleError>

Returns one error per passed definition that Yii can’t attach.

Parameters

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

Returns

list<PHPStan\Rules\IdentifierRuleError>: Errors reported at the list item, else at the definition argument or the call line.