# BehaviorsUnknownOptionRule

> Reports options of behavior configurations returned by yii\base\Component::behaviors() that the created yii\base\Behavior can't assign.

[API reference](/docs/api/index.md) › [PHPStan](/docs/extensions/phpstan/reference/index.md) › [rules](/docs/extensions/phpstan/reference/rules/index.md) › BehaviorsUnknownOptionRule

| final class | `yii2\extensions\phpstan\rules\BehaviorsUnknownOptionRule` |
| --- | --- |
| Implements | [`Rule`](https://apiref.phpstan.org/2.3.x/PHPStan.Rules.Rule.html) |
| Source | [`src/rules/BehaviorsUnknownOptionRule.php`](https://github.com/yii2-extensions/phpstan/blob/main/src/rules/BehaviorsUnknownOptionRule.php#L24) |

Reports options of behavior configurations returned by [`Component::behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) that the created
[`Behavior`](/docs/api/yii/base/behavior/index.md) can't assign.

[`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md) for the configurations the rule reads and those it stands aside on.
[`ObjectOptionAssignment`](/docs/extensions/phpstan/reference/rules/objectoptionassignment/index.md) for the assignment semantics.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Initializes the rule with class reflection and the analysis configuration. | `BehaviorsUnknownOptionRule` |
| [`getNodeType()`](#method-getNodeType) | Returns the node class this rule analyses. | `BehaviorsUnknownOptionRule` |
| [`processNode()`](#method-processNode) | Returns one error per behavior option that Yii can't assign. | `BehaviorsUnknownOptionRule` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
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\Reflection\ReflectionProvider` | Provides class reflection for owners and behavior classes. |
| `$serviceMap` | [`yii2\extensions\phpstan\ServiceMap`](/docs/extensions/phpstan/reference/servicemap/index.md) | Service and component map for Yii Application static analysis. |

### getNodeType() <span id="method-getNodeType"></span>

```php
public function getNodeType(): class-string<PhpParser\Node\Stmt\Return_>
```

Returns the node class this rule analyses.

**Returns**

`class-string<PhpParser\Node\Stmt\Return_>`

### processNode() <span id="method-processNode"></span>

```php
public function processNode(PhpParser\Node\Stmt\Return_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<PHPStan\Rules\IdentifierRuleError>
```

Returns one error per behavior option that Yii can't assign.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$node` | `PhpParser\Node\Stmt\Return_` | Return statement to inspect. |
| `$scope` | `PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope` | Current PHPStan analysis scope. |

**Returns**

`list<PHPStan\Rules\IdentifierRuleError>`: Errors reported at the option key, else at the list item or the return line.