ApplicationPropertiesClassReflectionExtension
API reference › PHPStan › property › ApplicationPropertiesClassReflectionExtension
Resolves dynamic component properties on the Yii Application instance for PHPStan analysis.
Recognizes properties defined via configuration, dependency injection, or service mapping on base, web, and console
application contexts, even when not declared natively. Delegates to annotation-based and native property reflection,
and resolves component types (including generics) through the ServiceMap.
Application for Yii Base Application class.
Application for Yii Console Application class.
Application for Yii Web Application class.
PropertiesClassReflectionExtension for custom properties class reflection extension contract.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates a new instance of the ApplicationPropertiesClassReflectionExtension class. | ApplicationPropertiesClassReflectionExtension |
getProperty() | Retrieves the property reflection for a given property on the Yii Application class or its components. | ApplicationPropertiesClassReflectionExtension |
hasProperty() | Determines whether the specified property exists on the Yii Application class or its components. | ApplicationPropertiesClassReflectionExtension |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(PHPStan\Reflection\Annotations\AnnotationsPropertiesClassReflectionExtension $annotationsProperties, PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap, PHPStan\Analyser\DeclarationDependencyTracker $dependencyTracker, string[] $genericComponents = [])Creates a new instance of the ApplicationPropertiesClassReflectionExtension class.
Parameters
| Parameter | Type | Description |
|---|---|---|
$annotationsProperties | AnnotationsPropertiesClassReflectionExtension | Extension for handling annotation-based properties. |
$reflectionProvider | PHPStan\ | Reflection provider for class and property lookups. |
$serviceMap | yii2\ | Service and component map for Yii Application static analysis. |
$dependencyTracker | PHPStan\ | Records the configuration values each class declaration depends on. |
$genericComponents | string[] | Optional mapping of component property names to their generic type parameter keys in the component definition. |
getProperty()
Section titled “getProperty() ”public function getProperty(PHPStan\Reflection\ClassReflection $classReflection, string $propertyName): PHPStan\Reflection\PropertyReflectionRetrieves the property reflection for a given property on the Yii Application class or its components.
Resolves, in order, a native property of the configured application type, a configured component, an
annotation-based property, and a configured component whose class can’t be determined, typed as object. Such a
component takes precedence over the annotation, since its definition decides the value, unless it’s an array
without a class key, which Yii completes from the core component the annotation describes. PHPStan calls this
method only after hasProperty() returned true for the same class and property name.
Parameters
| Parameter | Type | Description |
|---|---|---|
$classReflection | PHPStan\ | Reflection of the class being analyzed. |
$propertyName | string | Name of the property to resolve. |
Returns
PropertyReflection: Property reflection instance for the specified property.
Throws
PHPStan\ShouldNotHappenException: if the property is neither native, a configured component, nor annotation-based.
hasProperty()
Section titled “hasProperty() ”public function hasProperty(PHPStan\Reflection\ClassReflection $classReflection, string $propertyName): boolDetermines whether the specified property exists on the Yii Application class or its components.
Applies only to Application and its subclasses, and checks native properties, dynamic components
registered via the service map, annotation-based properties, and components configured with an unknown class,
in the same order as getProperty().
Parameters
| Parameter | Type | Description |
|---|---|---|
$classReflection | PHPStan\ | Reflection of the class being analyzed. |
$propertyName | string | Name of the property to resolve. |
Returns
bool: true if the property exists as a native, component, or annotated property; false otherwise.