NewObjectConfigurationResolver
API reference › PHPStan › rules › NewObjectConfigurationResolver
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.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Initializes the resolver with class reflection. | NewObjectConfigurationResolver |
resolve() | Returns the configuration that the inherited BaseObject constructor assigns to the constructed class. | NewObjectConfigurationResolver |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider)Initializes the resolver with class reflection.
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionProvider | PHPStan\ | Provides class reflection for the constructed class. |
resolve()
Section titled “resolve() ”public function resolve(PhpParser\Node\Expr\New_ $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): yii2\extensions\phpstan\rules\NewObjectConfiguration|nullReturns 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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Construction to inspect. |
$scope | PHPStan\ | Current 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.