Skip to content
PHP Ecosystem
Explore

ComponentResolver

API reference › Debug › ComponentResolver

final classyii\debug\ComponentResolver
Sourcesrc/ComponentResolver.php

Normalizes Yii component configuration values into a resolvable type and its remaining properties.

MethodDescriptionDefined by
classAndProperties() staticSplits a configuration value into a resolvable class or container identifier and its remaining properties.ComponentResolver
createMapped() staticCreates the object described by an action-map entry, validating the named class before instantiation.ComponentResolver
public static function classAndProperties(array<array-key, mixed>|string $config, string|null $defaultClass = null): array{string|null, array<array-key, mixed>}

Splits a configuration value into a resolvable class or container identifier and its remaining properties.

The Yii-specific __class key takes precedence over class, matching Yii::createObject().

Parameters

ParameterTypeDescription
$configarray<array-key, mixed>|stringClass/container ID or configuration array with a type key.
$defaultClassstring|nullType assumed when a configuration array omits both type keys.

Returns

array{string|null, array<array-key, mixed>}: Resolvable type (or null) and configuration properties without the class and __class entries.

public static function createMapped(mixed $config): object|null

Creates the object described by an action-map entry, validating the named class before instantiation.

Parameters

ParameterTypeDescription
$configmixedAction-map entry accepted by Yii::createObject().

Returns

object|null: Instantiated object, or null when the entry is unresolvable or produces no object.

Throws