# ApplicationTypeNodeResolverExtension

> Resolves the PHPDoc types of Yii::$app and Module::$params declared by the stub shipped with this extension.

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

| final class | `yii2\extensions\phpstan\type\ApplicationTypeNodeResolverExtension` |
| --- | --- |
| Implements | [`TypeNodeResolverExtension`](https://apiref.phpstan.org/2.3.x/PHPStan.PhpDoc.TypeNodeResolverExtension.html) |
| Source | [`src/type/ApplicationTypeNodeResolverExtension.php`](https://github.com/yii2-extensions/phpstan/blob/main/src/type/ApplicationTypeNodeResolverExtension.php#L33) |

Resolves the PHPDoc types of `Yii::$app` and `Module::$params` declared by the stub shipped with this extension.

The static stub (`stubs/yii.stub`) declares both properties with the placeholder types [`APPLICATION_TYPE`](/docs/extensions/phpstan/reference/type/applicationtypenoderesolverextension/index.md#const-APPLICATION_TYPE) and
[`PARAMS_TYPE`](/docs/extensions/phpstan/reference/type/applicationtypenoderesolverextension/index.md#const-PARAMS_TYPE). This extension resolves them from the Yii configuration: the application placeholder to the
configured application class, and the params placeholder to the array shape built by [`ParamsTypeBuilder`](/docs/extensions/phpstan/reference/paramstypebuilder/index.md), or to
`array` when no params are configured. Every other type node is left to PHPStan.

Since the stub never changes, each resolution records that the class declaring the placeholder depends on the
configured application class or params shape. PHPStan propagates that dependency to every file depending on the
class or on a descendant, so a configuration change re-analyses the files that fetch, override, or inherit either
property.

[`TypeNodeResolverExtension`](https://apiref.phpstan.org/2.3.x/PHPStan.PhpDoc.TypeNodeResolverExtension.html) for PHPStan custom PHPDoc type contract.
[`ServiceMap`](/docs/extensions/phpstan/reference/servicemap/index.md) for service and component map for Yii Application static analysis.
[`ServiceMapResultCacheValueExtension`](/docs/extensions/phpstan/reference/servicemapresultcachevalueextension/index.md) for the tracked configuration values.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Initializes configuration-backed application and params type resolution. | `ApplicationTypeNodeResolverExtension` |
| [`resolve()`](#method-resolve) | Resolves the placeholder types of the shipped stub. | `ApplicationTypeNodeResolverExtension` |

## Constants

| Constant | Value | Description | Defined by |
| --- | --- | --- | --- |
| <span id="const-APPLICATION_TYPE"></span>`APPLICATION_TYPE` | `'yii2-extensions-phpstan-application'` | Placeholder PHPDoc type of `Yii::$app`, resolved to the configured application class. | `ApplicationTypeNodeResolverExtension` |
| <span id="const-PARAMS_TYPE"></span>`PARAMS_TYPE` | `'yii2-extensions-phpstan-params'` | Placeholder PHPDoc type of `Module::$params`, resolved to the configured params shape. | `ApplicationTypeNodeResolverExtension` |

## Method details

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

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

Initializes configuration-backed application and params type resolution.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$serviceMap` | [`yii2\extensions\phpstan\ServiceMap`](/docs/extensions/phpstan/reference/servicemap/index.md) | Service and component map for Yii Application static analysis. |
| `$reflectionProvider` | `PHPStan\Reflection\ReflectionProvider` | Reflection provider for the class declaring a placeholder. |
| `$dependencyTracker` | `PHPStan\Analyser\DeclarationDependencyTracker` | Records the configuration values each class declaration depends on. |

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

```php
public function resolve(PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, PHPStan\Analyser\NameScope $nameScope): PHPStan\Type\Type|null
```

Resolves the placeholder types of the shipped stub.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$typeNode` | `PHPStan\PhpDocParser\Ast\Type\TypeNode` | PHPDoc type node being resolved. |
| `$nameScope` | `PHPStan\Analyser\NameScope` | Name scope of the PHPDoc holding the type node. |

**Returns**

`PHPStan\Type\Type|null`: Configured application or params type, or `null` for any other type node.