WidgetConfigurationResolver
API reference › PHPStan › rules › WidgetConfigurationResolver
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.
Methods
Section titled “Methods”| Method | Description | Defined 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)Initializes the resolver with class reflection and the analysis configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
$reflectionProvider | PHPStan\ | Provides class reflection for the called and created classes. |
$serviceMap | yii2\ | Service and component map for Yii Application static analysis. |
resolve()
Section titled “resolve() ”public function resolve(PhpParser\Node\Expr\StaticCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): yii2\extensions\phpstan\rules\WidgetConfiguration|nullReturns 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
| Parameter | Type | Description |
|---|---|---|
$node | PhpParser\ | Static call to inspect. |
$scope | PHPStan\ | Current 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.