Skip to content
PHP Ecosystem
Explore

WidgetUnknownOptionRule

API reference › PHPStan › rules › WidgetUnknownOptionRule

final classyii2\extensions\phpstan\rules\WidgetUnknownOptionRule
ImplementsRule
Sourcesrc/rules/WidgetUnknownOptionRule.php

Reports Widget::widget() and Widget::begin() options that Yii can’t assign to the created widget.

on ... and as ... options are never reported, and other options only when no behavior can receive them. The class and __class keys with which Yii::createObject() selects the class are never reported; inside a constructor argument used as the configuration they are options like any other.

Rule for PHPStan rule contract. WidgetConfigurationResolver for the calls and classes the rule analyses. ObjectOptionAssignment for the assignment semantics.

MethodDescriptionDefined by
__construct()Initializes the rule with class reflection and the analysis configuration.WidgetUnknownOptionRule
getNodeType()Returns the node class this rule analyses.WidgetUnknownOptionRule
processNode()Returns one error per distinct option that the created widget can’t assign.WidgetUnknownOptionRule
public function __construct(PHPStan\Reflection\ReflectionProvider $reflectionProvider, yii2\extensions\phpstan\ServiceMap $serviceMap)

Initializes the rule 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 getNodeType(): class-string<PhpParser\Node\Expr\StaticCall>

Returns the node class this rule analyses.

Returns

class-string<PhpParser\Node\Expr\StaticCall>

public function processNode(PhpParser\Node\Expr\StaticCall $node, PHPStan\Analyser\DependencyTracker&PHPStan\Analyser\Scope $scope): list<PHPStan\Rules\IdentifierRuleError>

Returns one error per distinct option that the created widget can’t assign.

Parameters

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

Returns

list<PHPStan\Rules\IdentifierRuleError>: Errors reported at the first key of each unknown option, or at the call line when the configuration doesn’t locate the key.