# InvalidBehaviorOptionType

> Represents an option of a behavior configuration whose value the created yii\base\Behavior never accepts, as found by yii2\extensions\phpstan\rules\BehaviorDefinitionResolver.

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

| final readonly class | `yii2\extensions\phpstan\rules\InvalidBehaviorOptionType` |
| --- | --- |
| Source | [`src/rules/InvalidBehaviorOptionType.php`](https://github.com/yii2-extensions/phpstan/blob/main/src/rules/InvalidBehaviorOptionType.php#L16) |

Represents an option of a behavior configuration whose value the created [`Behavior`](/docs/api/yii/base/behavior/index.md) never accepts, as found by
[`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md).

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-actualType"></span>`$actualType` readonly constructor | `string` | Native type of the value, as PHPStan describes it precisely. | `InvalidBehaviorOptionType` |
| <span id="property-behaviorClass"></span>`$behaviorClass` readonly constructor | `string` | Behavior class that Yii creates, as PHPStan displays it. | `InvalidBehaviorOptionType` |
| <span id="property-calledClass"></span>`$calledClass` readonly constructor | `string\|null` | Class through which `createObject()` is called, for an `as` option, or `null`. Default: `null`. | `InvalidBehaviorOptionType` |
| <span id="property-expectedType"></span>`$expectedType` readonly constructor | `string` | Native type of that property or of the first setter parameter. | `InvalidBehaviorOptionType` |
| <span id="property-line"></span>`$line` readonly constructor | `int` | Line to report: the option key, else the list item, the definition argument, the `as` option, the return statement or the call. | `InvalidBehaviorOptionType` |
| <span id="property-member"></span>`$member` readonly constructor | `string` | Property or setter that Yii assigns the value to. | `InvalidBehaviorOptionType` |
| <span id="property-method"></span>`$method` readonly constructor | `string` | Method that supplies the configuration: `behaviors`, `attachBehavior`, `attachBehaviors` or `createObject`. | `InvalidBehaviorOptionType` |
| <span id="property-name"></span>`$name` readonly constructor | `int\|string\|null` | Behavior name: a string for a named behavior, an `int` for an anonymous one, `null` when the name isn't a single constant, or the `as` option name as written for `createObject`. | `InvalidBehaviorOptionType` |
| <span id="property-option"></span>`$option` readonly constructor | `string` | Name of the option whose value the behavior class never accepts. | `InvalidBehaviorOptionType` |
| <span id="property-owner"></span>`$owner` readonly constructor | `string` | Class whose `behaviors()` returns the configuration, receiver type of the attach call, or component created by `createObject()`, as PHPStan displays it. | `InvalidBehaviorOptionType` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Stores a rejected behavior option, its actual and expected types and diagnostic location. | `InvalidBehaviorOptionType` |
| [`message()`](#method-message) | Returns the diagnostic message, naming the behavior, its owner and source, the behavior class, the option, the value type and the type that the property or setter accepts. | `InvalidBehaviorOptionType` |

## Method details

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

```php
public function __construct(string $owner, string $method, int|string|null $name, int $line, string $behaviorClass, string $option, string $actualType, string $member, string $expectedType, string|null $calledClass = null)
```

Stores a rejected behavior option, its actual and expected types and diagnostic location.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$owner` | `string` | Class whose `behaviors()` returns the configuration, receiver type of the attach call, or component created by `createObject()`, as PHPStan displays it. |
| `$method` | `string` | Method that supplies the configuration: `behaviors`, `attachBehavior`, `attachBehaviors` or `createObject`. |
| `$name` | `int\|string\|null` | Behavior name: a string for a named behavior, an `int` for an anonymous one, `null` when the name isn't a single constant, or the `as` option name as written for `createObject`. |
| `$line` | `int` | Line to report: the option key, else the list item, the definition argument, the `as` option, the return statement or the call. |
| `$behaviorClass` | `string` | Behavior class that Yii creates, as PHPStan displays it. |
| `$option` | `string` | Name of the option whose value the behavior class never accepts. |
| `$actualType` | `string` | Native type of the value, as PHPStan describes it precisely. |
| `$member` | `string` | Property or setter that Yii assigns the value to. |
| `$expectedType` | `string` | Native type of that property or of the first setter parameter. |
| `$calledClass` | `string\|null` | Class through which `createObject()` is called, for an `as` option, or `null`. |

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

```php
public function message(): string
```

Returns the diagnostic message, naming the behavior, its owner and source, the behavior class, the option, the
value type and the type that the property or setter accepts.

**Returns**

`string`