# ApplicationClassResolver

> Validates the configured application type against PHPStan reflection and resolves its class reflection.

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

| final class | `yii2\extensions\phpstan\reflection\ApplicationClassResolver` |
| --- | --- |
| Source | [`src/reflection/ApplicationClassResolver.php`](https://github.com/yii2-extensions/phpstan/blob/main/src/reflection/ApplicationClassResolver.php#L26) |

Validates the configured application type against PHPStan reflection and resolves its class reflection.

The application type is validated where the analysis consumes it, not when the configuration is loaded: PHPStan
executes the configuration before `parameters.bootstrapFiles`, and only its reflection also discovers classes from
analysed paths and scanned files. A class PHPStan reflection can't discover, an interface, a trait, an enum, or a class
not extending [`Application`](/docs/api/yii/base/application/index.md) is rejected; [`Application`](/docs/api/yii/base/application/index.md) itself and every subclass are accepted.

Project stub validation reflects stub files only, where [`Application`](/docs/api/yii/base/application/index.md) is usually unknown and the application
hierarchy can't be established. When [`Application`](/docs/api/yii/base/application/index.md) can't be reflected, the class is returned unvalidated if it
can be reflected, or `null` otherwise, as before validation existed.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`resolve()`](#method-resolve) static | Returns the class reflection of the configured application type. | `ApplicationClassResolver` |

## Method details

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

```php
public static function resolve(string $applicationType, PHPStan\Reflection\ReflectionProvider $reflectionProvider): PHPStan\Reflection\ClassReflection|null
```

Returns the class reflection of the configured application type.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$applicationType` | `string` | Application type returned by [`ServiceMap`](/docs/extensions/phpstan/reference/servicemap/index.md), with or without a leading backslash. |
| `$reflectionProvider` | `PHPStan\Reflection\ReflectionProvider` | Reflection provider of the running analysis. |

**Returns**

`PHPStan\Reflection\ClassReflection|null`: Class reflection of the application type, or `null` if neither [`Application`](/docs/api/yii/base/application/index.md) nor the application type can be reflected.

**Throws**

- [`RuntimeException`](https://www.php.net/manual/en/class.runtimeexception.php): if [`Application`](/docs/api/yii/base/application/index.md) can be reflected and the application type doesn't name it or a class extending it.