class VersionSelector (View source)

Selects the best possible version for a package

Methods

__construct(Pool $pool)

No description

findBestCandidate(string $packageName, string $targetPackageVersion = null, string $targetPhpVersion = null, string $preferredStability = 'stable')

Given a package name and optional version, returns the latest PackageInterface that matches.

string
findRecommendedRequireVersion(PackageInterface $package)

Given a concrete version, this returns a ~ constraint (when possible) that should be used, for example, in composer.json.

Details

__construct(Pool $pool)

Parameters

Pool $pool

PackageInterface|bool findBestCandidate(string $packageName, string $targetPackageVersion = null, string $targetPhpVersion = null, string $preferredStability = 'stable')

Given a package name and optional version, returns the latest PackageInterface that matches.

Parameters

string $packageName
string $targetPackageVersion
string $targetPhpVersion
string $preferredStability

Return Value

PackageInterface|bool

string findRecommendedRequireVersion(PackageInterface $package)

Given a concrete version, this returns a ~ constraint (when possible) that should be used, for example, in composer.json.

For example: * 1.2.1 -> ^1.2 * 1.2 -> ^1.2 * v3.2.1 -> ^3.2 * 2.0-beta.1 -> ^2.0@beta * dev-master -> ^2.1@dev (dev version with alias) * dev-master -> dev-master (dev versions are untouched)

Parameters

PackageInterface $package

Return Value

string