# yii2\extensions\phpstan\rules

> 41 classes of the yii2\extensions\phpstan\rules namespace.

[API reference](/docs/api/index.md) › [PHPStan](/docs/extensions/phpstan/reference/index.md) › rules

## Classes

| Class | Summary |
| --- | --- |
| [`AttachBehaviorInvalidDefinitionRule`](/docs/extensions/phpstan/reference/rules/attachbehaviorinvaliddefinitionrule/index.md) final | Reports behavior definitions passed to [`Component::attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) or [`Component::attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) that Yii can't attach. |
| [`AttachBehaviorInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/attachbehaviorinvalidoptiontyperule/index.md) final | Reports option values of behavior configurations passed to [`Component::attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) or [`Component::attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) never accepts. |
| [`AttachBehaviorUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/attachbehaviorunknownoptionrule/index.md) final | Reports options of behavior configurations passed to [`Component::attachBehavior()`](/docs/api/yii/base/component/index.md#method-attachBehavior) or [`Component::attachBehaviors()`](/docs/api/yii/base/component/index.md#method-attachBehaviors) that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) can't assign. |
| [`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md) final | Finds behavior definitions that [`Component`](/docs/api/yii/base/component/index.md) can't attach, and behavior configuration options that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) can't assign or whose value it never accepts, in `behaviors()` returns, `attachBehavior()` and `attachBehaviors()` arguments and `as` options of `Yii::createObject()` configurations. |
| [`BehaviorsInvalidDefinitionRule`](/docs/extensions/phpstan/reference/rules/behaviorsinvaliddefinitionrule/index.md) final | Reports behavior definitions returned by [`Component::behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) that Yii can't attach. |
| [`BehaviorsInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/behaviorsinvalidoptiontyperule/index.md) final | Reports option values of behavior configurations returned by [`Component::behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) never accepts. |
| [`BehaviorsUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/behaviorsunknownoptionrule/index.md) final | Reports options of behavior configurations returned by [`Component::behaviors()`](/docs/api/yii/base/component/index.md#method-behaviors) that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) can't assign. |
| [`CreateObjectBehaviorInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/createobjectbehaviorinvalidoptiontyperule/index.md) final | Reports option values of behavior configurations in the `as` options of [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) configurations that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) never accepts. |
| [`CreateObjectBehaviorUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/createobjectbehaviorunknownoptionrule/index.md) final | Reports options of behavior configurations in the `as` options of [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) configurations that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) can't assign. |
| [`CreateObjectConfiguration`](/docs/extensions/phpstan/reference/rules/createobjectconfiguration/index.md) final readonly | Represents a [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) configuration whose class and assignment path are proven. |
| [`CreateObjectConfigurationResolver`](/docs/extensions/phpstan/reference/rules/createobjectconfigurationresolver/index.md) final | Resolves the class and options of a [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) call whose assignment path Yii makes certain. |
| [`CreateObjectConstructionContract`](/docs/extensions/phpstan/reference/rules/createobjectconstructioncontract/index.md) final readonly | Represents how an API constructs a configured object: the inherited constructor, the arguments the API supplies, the configuration parameter and what must hold before the configuration is applied. |
| [`CreateObjectInvalidAsDefinitionRule`](/docs/extensions/phpstan/reference/rules/createobjectinvalidasdefinitionrule/index.md) final | Reports `as` options of [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) configurations that the created [`Component`](/docs/api/yii/base/component/index.md) rejects or can't attach. |
| [`CreateObjectInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/createobjectinvalidoptiontyperule/index.md) final | Reports [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) option values that the property or setter Yii assigns them to never accepts. |
| [`CreateObjectUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/createobjectunknownoptionrule/index.md) final | Reports [`BaseYii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject) options that Yii can't assign to the created object. |
| [`ExternalActionConfiguration`](/docs/extensions/phpstan/reference/rules/externalactionconfiguration/index.md) final readonly | Represents an external action definition of [`Controller::actions()`](/docs/api/yii/base/controller/index.md#method-actions) whose class and assignment path are proven. |
| [`ExternalActionConfigurationResolver`](/docs/extensions/phpstan/reference/rules/externalactionconfigurationresolver/index.md) final | Resolves the external action definitions of a [`Controller::actions()`](/docs/api/yii/base/controller/index.md#method-actions) return statement whose assignment path Yii makes certain. |
| [`ExternalActionInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/externalactioninvalidoptiontyperule/index.md) final | Reports option values of external action definitions returned by [`Controller::actions()`](/docs/api/yii/base/controller/index.md#method-actions) that the property or setter Yii assigns them to never accepts, even with PHP's weak type coercion. |
| [`ExternalActionUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/externalactionunknownoptionrule/index.md) final | Reports options of external action definitions returned by [`Controller::actions()`](/docs/api/yii/base/controller/index.md#method-actions) that Yii can't assign to the created action. |
| [`InvalidBehaviorAsDefinition`](/docs/extensions/phpstan/reference/rules/invalidbehaviorasdefinition/index.md) final readonly | Represents an `as` option of a `Yii::createObject()` configuration that [`Component`](/docs/api/yii/base/component/index.md) rejects, as found by [`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md). |
| [`InvalidBehaviorDefinition`](/docs/extensions/phpstan/reference/rules/invalidbehaviordefinition/index.md) final readonly | Represents a behavior definition that [`Component`](/docs/api/yii/base/component/index.md) can't attach, as found by [`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md). |
| [`InvalidBehaviorOptionType`](/docs/extensions/phpstan/reference/rules/invalidbehavioroptiontype/index.md) final readonly | Represents an option of a behavior configuration whose value the created [`Behavior`](/docs/api/yii/base/behavior/index.md) never accepts, as found by [`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md). |
| [`ModelRulesReader`](/docs/extensions/phpstan/reference/rules/modelrulesreader/index.md) final | Reads the validation rules that a [`Model::rules()`](/docs/api/yii/base/model/index.md#method-rules) return passes unchanged to [`Model::createValidators()`](/docs/api/yii/base/model/index.md#method-createValidators), as proven by literals or by PHPStan's native types. |
| [`NewObjectConfiguration`](/docs/extensions/phpstan/reference/rules/newobjectconfiguration/index.md) final readonly | Represents the configuration of a direct `new` construction whose class and assignment path are proven. |
| [`NewObjectConfigurationResolver`](/docs/extensions/phpstan/reference/rules/newobjectconfigurationresolver/index.md) final | Resolves the class and configuration of a direct `new` construction whose assignment path Yii makes certain. |
| [`NewObjectInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/newobjectinvalidoptiontyperule/index.md) final | Reports configuration values of a direct `new` construction that the property or setter Yii assigns them to never accepts. |
| [`NewObjectUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/newobjectunknownoptionrule/index.md) final | Reports configuration options of a direct `new` construction that Yii can't assign to the constructed object. |
| [`ObjectConfigurationReader`](/docs/extensions/phpstan/reference/rules/objectconfigurationreader/index.md) final | Reads the options of a Yii object configuration whose keys are proven by literals or by PHPStan's native types. |
| [`ObjectOptionAssignment`](/docs/extensions/phpstan/reference/rules/objectoptionassignment/index.md) final | Decides how Yii assigns configuration options to a [`BaseObject`](/docs/api/yii/base/baseobject/index.md) or [`Component`](/docs/api/yii/base/component/index.md) subclass through [`BaseYii::configure()`](/docs/api/yii/baseyii/index.md#method-configure) and `__set()`, independently of how the object is constructed. |
| [`UnknownBehaviorOption`](/docs/extensions/phpstan/reference/rules/unknownbehavioroption/index.md) final readonly | Represents an option of a behavior configuration that the created [`Behavior`](/docs/api/yii/base/behavior/index.md) can't assign, as found by [`BehaviorDefinitionResolver`](/docs/extensions/phpstan/reference/rules/behaviordefinitionresolver/index.md). |
| [`ValidatorConfiguration`](/docs/extensions/phpstan/reference/rules/validatorconfiguration/index.md) final readonly | Represents the configuration of a `Model::rules()` entry whose created [`Validator`](/docs/api/yii/validators/validator/index.md) and assignment path are proven. |
| [`ValidatorConfigurationResolver`](/docs/extensions/phpstan/reference/rules/validatorconfigurationresolver/index.md) final readonly | Resolves the validator class and options that [`Validator::createValidator()`](/docs/api/yii/validators/validator/index.md#method-createValidator) passes to `Yii::createObject()` for a `Model::rules()` entry using a closure, a qualified class name or one of Yii's declared built-in aliases. |
| [`ValidatorIncompleteRuleRule`](/docs/extensions/phpstan/reference/rules/validatorincompleterulerule/index.md) final | Reports validation rules returned by [`Model::rules()`](/docs/api/yii/base/model/index.md#method-rules) that [`Model::createValidators()`](/docs/api/yii/base/model/index.md#method-createValidators) rejects because the rule has no non-null attribute names at key `0` or validator type at key `1`. |
| [`ValidatorInvalidDefinitionRule`](/docs/extensions/phpstan/reference/rules/validatorinvaliddefinitionrule/index.md) final | Reports validation rules returned by [`Model::rules()`](/docs/api/yii/base/model/index.md#method-rules) whose validator type at key `1` is an array or an object other than a [`Closure`](https://www.php.net/manual/en/class.closure.php), which [`Validator::createValidator()`](/docs/api/yii/validators/validator/index.md#method-createValidator) looks up as a key of `Validator::$builtInValidators` and so rejects with a [`TypeError`](https://www.php.net/manual/en/class.typeerror.php). |
| [`ValidatorInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/validatorinvalidoptiontyperule/index.md) final readonly | Reports option values written in model validation rules that the property or setter of the validator Yii creates never accepts. |
| [`ValidatorMissingRequiredOptionRule`](/docs/extensions/phpstan/reference/rules/validatormissingrequiredoptionrule/index.md) final readonly | Reports model validation rules that create [`RangeValidator`](/docs/api/yii/validators/rangevalidator/index.md), [`RegularExpressionValidator`](/docs/api/yii/validators/regularexpressionvalidator/index.md) or [`FilterValidator`](/docs/api/yii/validators/filtervalidator/index.md) without the `range`, `pattern` or `filter` option, whose absence or `null` value makes the validator's `init()` throw an `InvalidConfigException`. |
| [`ValidatorUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/validatorunknownoptionrule/index.md) final readonly | Reports unknown options in model validation rules using closures, qualified classes or Yii's declared built-in aliases. |
| [`WidgetConfiguration`](/docs/extensions/phpstan/reference/rules/widgetconfiguration/index.md) final readonly | Represents the configuration of a [`Widget::widget()`](/docs/api/yii/base/widget/index.md#method-widget) or [`Widget::begin()`](/docs/api/yii/base/widget/index.md#method-begin) call whose class and assignment path are proven. |
| [`WidgetConfigurationResolver`](/docs/extensions/phpstan/reference/rules/widgetconfigurationresolver/index.md) final | Resolves the widget class and options of a [`Widget::widget()`](/docs/api/yii/base/widget/index.md#method-widget) or [`Widget::begin()`](/docs/api/yii/base/widget/index.md#method-begin) call whose assignment path Yii makes certain. |
| [`WidgetInvalidOptionTypeRule`](/docs/extensions/phpstan/reference/rules/widgetinvalidoptiontyperule/index.md) final | Reports [`Widget::widget()`](/docs/api/yii/base/widget/index.md#method-widget) and [`Widget::begin()`](/docs/api/yii/base/widget/index.md#method-begin) option values that the property or setter Yii assigns them to never accepts. |
| [`WidgetUnknownOptionRule`](/docs/extensions/phpstan/reference/rules/widgetunknownoptionrule/index.md) final | Reports [`Widget::widget()`](/docs/api/yii/base/widget/index.md#method-widget) and [`Widget::begin()`](/docs/api/yii/base/widget/index.md#method-begin) options that Yii can't assign to the created widget. |