# ExternalActionInvalidOptionTypeRule

> Reports option values of external action definitions returned by yii\base\Controller::actions() that the property or setter Yii assigns them to never accepts, even with PHP's weak type coercion.

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

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

Reports option values of external action definitions returned by [`Controller::actions()`](/docs/api/yii/base/controller/index.md#method-actions) that the property or
setter Yii assigns them to never accepts, even with PHP's weak type coercion.

[`ExternalActionConfigurationResolver`](/docs/extensions/phpstan/reference/rules/externalactionconfigurationresolver/index.md) for the definitions the rule analyses.
[`CreateObjectConfigurationResolver::rejectedOptions()`](/docs/extensions/phpstan/reference/rules/createobjectconfigurationresolver/index.md#method-rejectedOptions) for the type semantics.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Initializes the rule with class reflection and the analysis configuration. | `ExternalActionInvalidOptionTypeRule` |
| [`getNodeType()`](#method-getNodeType) | Returns the node class this rule analyses. | `ExternalActionInvalidOptionTypeRule` |
| [`processNode()`](#method-processNode) | Returns one error per distinct option whose value the created action never accepts. | `ExternalActionInvalidOptionTypeRule` |

## 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 the created actions. |
| `$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 distinct option whose value the created action never accepts.

**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 first key of each option, else at the definition line, else at the return line.