Skip to content
PHP Ecosystem
Explore

VersionResolver

API reference › Debug › VersionResolver

final classyii\debug\VersionResolver
Sourcesrc/VersionResolver.php

Resolves human-readable Composer package versions for the debug UI.

Replaces Composer’s synthetic dev placeholders (22.0.9999999.9999999-dev, dev-master) with the package alias plus the short Git reference, producing strings such as 22.x-dev @a1b2c3d or 2.0.45.

MethodDescriptionDefined by
forExtensions() staticRewrites the version field of each entry with the friendly version, when resolvable.VersionResolver
forPackage() staticReturns a friendly version string for a Composer package.VersionResolver
yii() staticReturns the Yii framework version for the toolbar brand chip.VersionResolver
public static function forExtensions(array<int|string, array{name?: string, version?: string, bootstrap?: string|array<string, mixed>, alias?: array<string, string>}> $extensions): array<int|string, array{name?: string, version?: string, bootstrap?: string|array<string, mixed>, alias?: array<string, string>}>

Rewrites the version field of each entry with the friendly version, when resolvable.

Accepts the array shape produced by Yii::$app->extensions; [$packageName => ['name' => ..., 'version' => ...]]. Entries whose key is not a string (malformed registrations) or whose package cannot be resolved through Composer are returned unchanged.

Parameters

ParameterTypeDescription
$extensionsarray<int|string, array{name?: string, version?: string, bootstrap?: string|array<string, mixed>, alias?: array<string, string>}>Extension map keyed by package name.

Returns

array<int|string, array{name?: string, version?: string, bootstrap?: string|array<string, mixed>, alias?: array<string, string>}>: Extension map with version fields rewritten in place.

public static function forPackage(string $package): string|null

Returns a friendly version string for a Composer package.

Tagged releases are returned verbatim. Dev branches are augmented with the 7-character Git short hash so two builds of the same branch can be told apart.

Parameters

ParameterTypeDescription
$packagestringComposer package name (vendor/package).

Returns

string|null: Friendly version, or null when the package is not installed or has no pretty version.

public static function yii(): string

Returns the Yii framework version for the toolbar brand chip.

Returns

string: Yii version label for the brand chip.