CreateObjectConstructionContract
API reference › PHPStan › rules › CreateObjectConstructionContract
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.
Closed contract with two instances, baseObject() and externalAction().
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$configurationName readonly constructor | string | Name of the configuration parameter. | CreateObjectConstructionContract |
$configurationPosition readonly constructor | int | Position of the configuration parameter, the last one. | CreateObjectConstructionContract |
$constructorClass readonly constructor | string | Class that must declare the inherited constructor. | CreateObjectConstructionContract |
$fixedArgumentPositions readonly constructor | list<int> | Positions of the arguments the API supplies, 0 up to the configuration. | CreateObjectConstructionContract |
$followsConstructorArguments readonly constructor | bool | Whether a __construct() option and definition params that address only the configuration parameter are followed; otherwise any of them leaves the configuration unresolved. | CreateObjectConstructionContract |
$propertiesWrittenBeforeConfiguration readonly constructor | list<string> | Properties the constructor assigns before the configuration, which must be plain public properties. | CreateObjectConstructionContract |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
baseObject() static | Returns the contract of BaseObject::__construct(), used by Yii::createObject(), new and widgets. | CreateObjectConstructionContract |
externalAction() static | Returns the contract of Action::__construct() for Yii::createObject($definition, in Controller::createAction(). | CreateObjectConstructionContract |
isInheritedConstructor() | Returns whether the class inherits the contract’s constructor with one variant whose parameters are the supplied arguments followed by the configuration parameter; optionality isn’t compared. | CreateObjectConstructionContract |
Method details
Section titled “Method details”baseObject()
Section titled “baseObject() ”public static function baseObject(): selfReturns the contract of BaseObject::__construct(), used by Yii::createObject(), new and widgets.
Returns
self
externalAction()
Section titled “externalAction() ”public static function externalAction(): selfReturns the contract of Action::__construct() for Yii::createObject($definition, [$id, $this]) in
Controller::createAction().
Returns
self
isInheritedConstructor()
Section titled “isInheritedConstructor() ”public function isInheritedConstructor(PHPStan\Reflection\ClassReflection $classReflection): boolReturns whether the class inherits the contract’s constructor with one variant whose parameters are the supplied arguments followed by the configuration parameter; optionality isn’t compared.
Parameters
| Parameter | Type | Description |
|---|---|---|
$classReflection | PHPStan\ |
Returns
bool