Skip to content
PHP Ecosystem
Explore

ApplicationTypeNodeResolverExtension

API reference › PHPStan › type › ApplicationTypeNodeResolverExtension

final classyii2\extensions\phpstan\type\ApplicationTypeNodeResolverExtension
ImplementsTypeNodeResolverExtension
Sourcesrc/type/ApplicationTypeNodeResolverExtension.php

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.

MethodDescriptionDefined by
__construct()Initializes configuration-backed application and params type resolution.ApplicationTypeNodeResolverExtension
resolve()Resolves the placeholder types of the shipped stub.ApplicationTypeNodeResolverExtension
ConstantValueDescriptionDefined 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
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

ParameterTypeDescription
$serviceMapyii2\extensions\phpstan\ServiceMapService and component map for Yii Application static analysis.
$reflectionProviderPHPStan\Reflection\ReflectionProviderReflection provider for the class declaring a placeholder.
$dependencyTrackerPHPStan\Analyser\DeclarationDependencyTrackerRecords the configuration values each class declaration depends on.
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

ParameterTypeDescription
$typeNodePHPStan\PhpDocParser\Ast\Type\TypeNodePHPDoc type node being resolved.
$nameScopePHPStan\Analyser\NameScopeName 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.