Composer API
Class

Composer\Package\Version\VersionSelector

class VersionSelector

Selects the best possible version for a package

Methods

__construct(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.

string findRecommendedRequireVersion(PackageInterface $package)

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

Details

at line 34
public __construct(Pool $pool)

Parameters

Pool $pool

at line 49
public 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

at line 118
public 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