Skip to content
PHP Ecosystem
Explore

NewObjectUnknownOptionRule

API reference › PHPStan › rules › NewObjectUnknownOptionRule

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

Reports configuration options of a direct new construction that Yii can’t assign to the constructed object.

Every key is assigned, so class, __class and __construct() are checked like any other name. For a Component subclass, on ... and as ... options are never reported, and other options only when no behavior can receive them.

Rule for PHPStan rule contract. NewObjectConfigurationResolver for the constructions and classes the rule analyses. ObjectOptionAssignment for the assignment semantics.

MethodDescriptionDefined by
__construct()Initializes the rule with class reflection and the analysis configuration.NewObjectUnknownOptionRule
getNodeType()Returns the node class this rule analyses.NewObjectUnknownOptionRule
processNode()Returns one error per distinct option that the constructed class can’t assign.NewObjectUnknownOptionRule
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 constructed class.
$serviceMapyii2\extensions\phpstan\ServiceMapService and component map for Yii Application static analysis, read only for the behaviors map.
public function getNodeType(): class-string<PhpParser\Node\Expr\New_>

Returns the node class this rule analyses.

Returns

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

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

Returns one error per distinct option that the constructed class can’t assign.

Parameters

ParameterTypeDescription
$nodePhpParser\Node\Expr\New_Construction 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 line of new when the configuration doesn’t locate the key.