Skip to content
PHP Ecosystem
Explore

ParamsTypeBuilder

API reference › PHPStan › ParamsTypeBuilder

final classyii2\extensions\phpstan\ParamsTypeBuilder
Sourcesrc/ParamsTypeBuilder.php

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() for the configured params. ApplicationTypeNodeResolverExtension for the Module::$params type resolved from this shape.

MethodDescriptionDefined by
build() staticBuilds the array shape type for the given params.ParamsTypeBuilder
public static function build(array<array-key, mixed> $params): PHPStan\Type\Type

Builds the array shape type for the given params.

Parameters

ParameterTypeDescription
$paramsarray<array-key, mixed>Configured params, as returned by ServiceMap::getParams().

Returns

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