# ParamsTypeBuilder

> Builds the PHPStan array shape type of Yii application params from their configured values.

[API reference](/docs/api/index.md) › [PHPStan](/docs/extensions/phpstan/reference/index.md) › ParamsTypeBuilder

| final class | `yii2\extensions\phpstan\ParamsTypeBuilder` |
| --- | --- |
| Source | [`src/ParamsTypeBuilder.php`](https://github.com/yii2-extensions/phpstan/blob/main/src/ParamsTypeBuilder.php#L31) |

Builds the PHPStan array shape type of Yii application params from their configured values.

Scalars are generalized to `string`, `int`, `float` and `bool`, `null` stays `null`, nested arrays become nested
shapes (lists become positional shapes), empty arrays become `array<mixed, mixed>`, and any other value becomes
explicit `mixed`, matching what the same shape written as a PHPDoc type resolves to. Shapes are never degraded to
general arrays, regardless of the number of keys, which is also how PHPStan resolves a PHPDoc array shape.

[`ServiceMap::getParams()`](/docs/extensions/phpstan/reference/servicemap/index.md#method-getParams) for the configured params.
[`ApplicationTypeNodeResolverExtension`](/docs/extensions/phpstan/reference/type/applicationtypenoderesolverextension/index.md) for the `Module::$params` type resolved from this shape.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`build()`](#method-build) static | Builds the array shape type for the given params. | `ParamsTypeBuilder` |

## Method details

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

```php
public static function build(array<array-key, mixed> $params): PHPStan\Type\Type
```

Builds the array shape type for the given params.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$params` | `array<array-key, mixed>` | Configured params, as returned by [`ServiceMap::getParams()`](/docs/extensions/phpstan/reference/servicemap/index.md#method-getParams). |

**Returns**

`PHPStan\Type\Type`: Array shape type, or `array<mixed, mixed>` for an empty array.