Skip to content
PHP Ecosystem
Explore

WidgetConfigurationResolver

API reference › PHPStan › rules › WidgetConfigurationResolver

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

Resolves the widget class and options of a Widget::widget() or Widget::begin() call whose assignment path Yii makes certain.

Both methods set the class key of their configuration to the called class and pass it to BaseYii::createObject() without $params, so the configuration is resolved as CreateObjectConfigurationResolver::resolveTypeOptions() resolves that array: a non-null __class value selects the class instead, and container definitions, __construct() and the configurable class are handled as for Yii::createObject().

Requires the called class written as a name (an imported alias or a fully qualified name, never self, parent or static) that is Widget or a subclass, a method that Widget declares and the class doesn’t override, the configuration as the only argument by position or by its parameter name and proven as ObjectConfigurationReader::options() describes, and a created class that is a Widget subclass.

MethodDescriptionDefined by
__construct()Initializes the resolver with class reflection and the analysis configuration.WidgetConfigurationResolver
resolve()Returns the configuration that Yii assigns to the widget that the call creates.WidgetConfigurationResolver
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)

Initializes the resolver with class reflection and the analysis configuration.

Parameters

ParameterTypeDescription
$reflectionProviderPHPStan\Reflection\ReflectionProviderProvides class reflection for the called and created classes.
$serviceMapyii2\extensions\phpstan\ServiceMapService and component map for Yii Application static analysis.
public function resolve(PhpParser\Node\Expr\StaticCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): yii2\extensions\phpstan\rules\WidgetConfiguration|null

Returns the configuration that Yii assigns to the widget that the call creates.

Records the declaration dependency of the called class before deciding, so that the result cache reanalyses the call when that class starts or stops overriding the method, and the construction and declaration dependencies of CreateObjectConfigurationResolver::resolveTypeOptions().

Parameters

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

Returns

WidgetConfiguration|null: Resolved configuration, or null when the call, its configuration or the created widget isn’t proven, or the call has no configuration.