# ComponentResolver

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

[API reference](/docs/api/index.md) › [Debug](/docs/extensions/debug/reference/index.md) › ComponentResolver

| final class | `yii\debug\ComponentResolver` |
| --- | --- |
| Source | [`src/ComponentResolver.php`](https://github.com/yii2-extensions/debug/blob/main/src/ComponentResolver.php#L19) |

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

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`classAndProperties()`](#method-classAndProperties) static | Splits a configuration value into a resolvable class or container identifier and its remaining properties. | `ComponentResolver` |
| [`createMapped()`](#method-createMapped) static | Creates the object described by an action-map entry, validating the named class before instantiation. | `ComponentResolver` |

## Method details

### classAndProperties() <span id="method-classAndProperties"></span>

```php
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()`](/docs/api/yii/baseyii/index.md#method-createObject).

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$config` | `array<array-key, mixed>\|string` | Class/container ID or configuration array with a type key. |
| `$defaultClass` | `string\|null` | Type 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.

### createMapped() <span id="method-createMapped"></span>

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

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

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$config` | `mixed` | Action-map entry accepted by [`Yii::createObject()`](/docs/api/yii/baseyii/index.md#method-createObject). |

**Returns**

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

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): when object creation fails for a resolvable configuration.