Skip to content
PHP Ecosystem
Explore

ApplicationPropertiesClassReflectionExtension

API reference › PHPStan › property › ApplicationPropertiesClassReflectionExtension

final classyii2\extensions\phpstan\property\ApplicationPropertiesClassReflectionExtension
ImplementsPropertiesClassReflectionExtension
Sourcesrc/property/ApplicationPropertiesClassReflectionExtension.php

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.

MethodDescriptionDefined 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
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

ParameterTypeDescription
$annotationsPropertiesAnnotationsPropertiesClassReflectionExtensionExtension for handling annotation-based properties.
$reflectionProviderPHPStan\Reflection\ReflectionProviderReflection provider for class and property lookups.
$serviceMapyii2\extensions\phpstan\ServiceMapService and component map for Yii Application static analysis.
$dependencyTrackerPHPStan\Analyser\DeclarationDependencyTrackerRecords the configuration values each class declaration depends on.
$genericComponentsstring[]Optional mapping of component property names to their generic type parameter keys in the component definition.
public function getProperty(PHPStan\Reflection\ClassReflection $classReflection, string $propertyName): PHPStan\Reflection\PropertyReflection

Retrieves 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

ParameterTypeDescription
$classReflectionPHPStan\Reflection\ClassReflectionReflection of the class being analyzed.
$propertyNamestringName 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.
public function hasProperty(PHPStan\Reflection\ClassReflection $classReflection, string $propertyName): bool

Determines 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

ParameterTypeDescription
$classReflectionPHPStan\Reflection\ClassReflectionReflection of the class being analyzed.
$propertyNamestringName of the property to resolve.

Returns

bool: true if the property exists as a native, component, or annotated property; false otherwise.