# ValidatorUnknownOptionRule

> Reports unknown options in model validation rules using closures, qualified classes or Yii's declared built-in aliases.

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

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

Reports unknown options in model validation rules using closures, qualified classes or Yii's declared built-in aliases.

Assumes the declared alias table has not been changed at runtime. Method names and uncertain dispatches stand aside.
[`ValidatorConfigurationResolver`](/docs/extensions/phpstan/reference/rules/validatorconfigurationresolver/index.md) for the dispatch and [`ObjectOptionAssignment`](/docs/extensions/phpstan/reference/rules/objectoptionassignment/index.md) for the assignment semantics.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Initializes static class reflection and the analysis service map. | `ValidatorUnknownOptionRule` |
| [`getNodeType()`](#method-getNodeType) | Returns the node class this rule analyses. | `ValidatorUnknownOptionRule` |
| [`processNode()`](#method-processNode) | Returns diagnostics for unknown options explicitly written in model rules. | `ValidatorUnknownOptionRule` |

## Method details

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

```php
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)
```

Initializes static class reflection and the analysis service map.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$reflectionProvider` | `PHPStan\Reflection\ReflectionProvider` |  |
| `$serviceMap` | [`yii2\extensions\phpstan\ServiceMap`](/docs/extensions/phpstan/reference/servicemap/index.md) |  |

### 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 diagnostics for unknown options explicitly written in model rules.

**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 at each rule's line.