Skip to content
PHP Ecosystem
Explore

NewObjectConfigurationResolver

API reference › PHPStan › rules › NewObjectConfigurationResolver

final classyii2\extensions\phpstan\rules\NewObjectConfigurationResolver
Sourcesrc/rules/NewObjectConfigurationResolver.php

Resolves the class and configuration of a direct new construction whose assignment path Yii makes certain.

Requires a class name written in the expression (an imported alias, self or parent, or static in a final class, never inside a closure or an arrow function), a class that inherits the constructor of BaseObject and the __set() of BaseObject or Component, and a configuration passed to that constructor’s parameter by position or by name and proven as ObjectConfigurationReader::options() describes.

new doesn’t consult Yii::$container, so container definitions never change the constructed class, and BaseYii::configure() assigns every key of the configuration.

MethodDescriptionDefined by
__construct()Initializes the resolver with class reflection.NewObjectConfigurationResolver
resolve()Returns the configuration that the inherited BaseObject constructor assigns to the constructed class.NewObjectConfigurationResolver
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider)

Initializes the resolver with class reflection.

Parameters

ParameterTypeDescription
$reflectionProviderPHPStan\Reflection\ReflectionProviderProvides class reflection for the constructed class.
public function resolve(PhpParser\Node\Expr\New_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): yii2\extensions\phpstan\rules\NewObjectConfiguration|null

Returns the configuration that the inherited BaseObject constructor assigns to the constructed class.

Records the declaration dependency of the constructed class once known, so that the result cache reanalyses the construction when that class, a parent class or a trait changes.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\New_Construction to inspect.
$scopePHPStan\Analyser\DependencyTracker&PHPStan\Analyser\ScopeCurrent PHPStan analysis scope.

Returns

NewObjectConfiguration|null: Resolved configuration, or null when the class, its constructor and __set(), the arguments or the configuration isn’t proven.