ApplicationTypeNodeResolverExtension
API reference › PHPStan › type › ApplicationTypeNodeResolverExtension
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 and
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, 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 for PHPStan custom PHPDoc type contract.
ServiceMap for service and component map for Yii Application static analysis.
ServiceMapResultCacheValueExtension for the tracked configuration values.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Initializes configuration-backed application and params type resolution. | ApplicationTypeNodeResolverExtension |
resolve() | Resolves the placeholder types of the shipped stub. | ApplicationTypeNodeResolverExtension |
Constants
Section titled “Constants”| Constant | Value | Description | Defined by |
|---|---|---|---|
APPLICATION_TYPE | 'yii2-extensions-phpstan-application' | Placeholder PHPDoc type of Yii::$app, resolved to the configured application class. | ApplicationTypeNodeResolverExtension |
PARAMS_TYPE | 'yii2-extensions-phpstan-params' | Placeholder PHPDoc type of Module::$params, resolved to the configured params shape. | ApplicationTypeNodeResolverExtension |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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\ | Service and component map for Yii Application static analysis. |
$reflectionProvider | PHPStan\ | Reflection provider for the class declaring a placeholder. |
$dependencyTracker | PHPStan\ | Records the configuration values each class declaration depends on. |
resolve()
Section titled “resolve() ”public function resolve(PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, PHPStan\Analyser\NameScope $nameScope): PHPStan\Type\Type|nullResolves the placeholder types of the shipped stub.
Parameters
| Parameter | Type | Description |
|---|---|---|
$typeNode | PHPStan\ | PHPDoc type node being resolved. |
$nameScope | PHPStan\ | 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.