AttachBehaviorInvalidOptionTypeRule
API reference › PHPStan › rules › AttachBehaviorInvalidOptionTypeRule
Reports option values of behavior configurations passed to Component::attachBehavior() or
Component::attachBehaviors() that the created Behavior never accepts.
BehaviorDefinitionResolver for the configurations the rule reads and those it stands aside on.
ObjectOptionAssignment for the assignment semantics.
CreateObjectConfigurationResolver::rejectedOptions() for the type coercion semantics.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Initializes the rule with class reflection and the analysis configuration. | AttachBehaviorInvalidOptionTypeRule |
getNodeType() | Returns the node class this rule analyses. | AttachBehaviorInvalidOptionTypeRule |
processNode() | Returns one error per behavior option whose value the created behavior never accepts. | AttachBehaviorInvalidOptionTypeRule |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)Initializes the rule with class reflection and the analysis configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionProvider | PHPStan\ | Provides class reflection for owners and behavior classes. |
$serviceMap | yii2\ | Service and component map for Yii Application static analysis. |
getNodeType()
Section titled “getNodeType() ”public function getNodeType(): class-string<PhpParser\Node\Expr\MethodCall>Returns the node class this rule analyses.
Returns
class-string<PhpParser\Node\Expr\MethodCall>
processNode()
Section titled “processNode() ”public function processNode(PhpParser\Node\Expr\MethodCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<PHPStan\Rules\IdentifierRuleError>Returns one error per behavior option whose value the created behavior never accepts.
Parameters
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Method call to inspect. |
$scope | PHPStan\ | Current PHPStan analysis scope. |
Returns
list<PHPStan\Rules\IdentifierRuleError>: Errors reported at the option key, else at the list item, the definition argument or the call line.