Skip to content
PHP Ecosystem
Explore

StaticInstanceInterface

API reference › yii › base › StaticInstanceInterface

interfaceyii\base\StaticInstanceInterface
Since2.0.13
Sourceframework/base/StaticInstanceInterface.php
Implemented by 2 types

StaticInstanceInterface is the interface for providing static instances to classes, which can be used to obtain class meta information that can not be expressed in static methods.

For example: adjustments made by DI or behaviors reveal only at object level, but might be needed at class (static) level as well.

To implement the instance() method you may use StaticInstanceTrait.

See also: StaticInstanceTrait.

MethodDescriptionDefined by
instance() static abstractReturns static class instance, which can be used to obtain meta information.StaticInstanceInterface
abstract public static function instance(bool $refresh = false): static

Returns static class instance, which can be used to obtain meta information.

Parameters

ParameterTypeDescription
$refreshboolWhether to re-create static instance even, if it is already cached.

Returns

static: Class instance.