Skip to content
PHP Ecosystem
Explore

CreateObjectConstructionContract

API reference › PHPStan › rules › CreateObjectConstructionContract

final readonly classyii2\extensions\phpstan\rules\CreateObjectConstructionContract
Sourcesrc/rules/CreateObjectConstructionContract.php

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().

PropertyTypeDescriptionDefined by
$configurationName readonly constructorstringName of the configuration parameter.CreateObjectConstructionContract
$configurationPosition readonly constructorintPosition of the configuration parameter, the last one.CreateObjectConstructionContract
$constructorClass readonly constructorstringClass that must declare the inherited constructor.CreateObjectConstructionContract
$fixedArgumentPositions readonly constructorlist<int>Positions of the arguments the API supplies, 0 up to the configuration.CreateObjectConstructionContract
$followsConstructorArguments readonly constructorboolWhether 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 constructorlist<string>Properties the constructor assigns before the configuration, which must be plain public properties.CreateObjectConstructionContract
MethodDescriptionDefined by
baseObject() staticReturns the contract of BaseObject::__construct(), used by Yii::createObject(), new and widgets.CreateObjectConstructionContract
externalAction() staticReturns the contract of Action::__construct() for Yii::createObject($definition, [$id, $this]) 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
public static function baseObject(): self

Returns the contract of BaseObject::__construct(), used by Yii::createObject(), new and widgets.

Returns

self

public static function externalAction(): self

Returns the contract of Action::__construct() for Yii::createObject($definition, [$id, $this]) in Controller::createAction().

Returns

self

public function isInheritedConstructor(PHPStan\Reflection\ClassReflection $classReflection): bool

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.

Parameters

ParameterTypeDescription
$classReflectionPHPStan\Reflection\ClassReflection

Returns

bool