\Composer\Package\VersionVersionParser

Version parser.

Summary

Methods
Properties
Constants
parseStability()
normalizeStability()
normalize()
parseNumericAliasPrefix()
normalizeBranch()
parseConstraints()
parseNameVersionPairs()
isUpgrade()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
parseConstraint()
manipulateVersionString()
expandStability()
$modifierRegex
$stabilities
$constraints
N/A

Properties

$modifierRegex

$modifierRegex : string

Regex to match pre-release data (sort of).

Due to backwards compatibility:

  • Instead of enforcing hyphen, an underscore, dot or nothing at all are also accepted.
  • Only stabilities as recognized by Composer are allowed to precede a numerical identifier.
  • Numerical-only pre-release identifiers are not supported, see tests.

                   |--------------|

    [major].[minor].[patch] -[pre-release] +[build-metadata]

Type

string

$stabilities

$stabilities : array

Type

array

$constraints

$constraints : 

Type

Methods

parseStability()

parseStability(string  $version) : string

Returns the stability of a version.

Parameters

string $version

Returns

string

normalizeStability()

normalizeStability(string  $stability) : string

Parameters

string $stability

Returns

string

normalize()

normalize(string  $version, string  $fullVersion = null) : string

Normalizes a version string to be able to perform comparisons on it.

Parameters

string $version
string $fullVersion

optional complete version string to give more context

Throws

\UnexpectedValueException

Returns

string

parseNumericAliasPrefix()

parseNumericAliasPrefix(string  $branch) : string|false

Extract numeric prefix from alias, if it is in numeric format, suitable for version comparison.

Parameters

string $branch

Branch name (e.g. 2.1.x-dev)

Returns

string|false —

Numeric prefix if present (e.g. 2.1.) or false

normalizeBranch()

normalizeBranch(string  $name) : string

Normalizes a branch name to be able to perform comparisons on it.

Parameters

string $name

Returns

string

parseConstraints()

parseConstraints(string  $constraints) : \Composer\Semver\Constraint\ConstraintInterface

Parses a constraint string into MultiConstraint and/or Constraint objects.

Parameters

string $constraints

Returns

\Composer\Semver\Constraint\ConstraintInterface

parseNameVersionPairs()

parseNameVersionPairs(array  $pairs) : array<mixed,array>

Parses an array of strings representing package/version pairs.

The parsing results in an array of arrays, each of which contain a 'name' key with value and optionally a 'version' key with value.

Parameters

array $pairs

a set of package/version pairs separated by ":", "=" or " "

Returns

array<mixed,array> —

array of arrays containing a name and (if provided) a version

isUpgrade()

isUpgrade(  $normalizedFrom,   $normalizedTo) : boolean

Parameters

$normalizedFrom
$normalizedTo

Returns

boolean

parseConstraint()

parseConstraint(string  $constraint) : array

Parameters

string $constraint

Throws

\UnexpectedValueException

Returns

array

manipulateVersionString()

manipulateVersionString(array  $matches, integer  $position, integer  $increment, string  $pad = '0') : string

Increment, decrement, or simply pad a version number.

Support function for \Composer\Semver\parseConstraint()

Parameters

array $matches

Array with version parts in array indexes 1,2,3,4

integer $position

1,2,3,4 - which segment of the version to increment/decrement

integer $increment
string $pad

The string to pad version parts after $position

Returns

string —

The new version

expandStability()

expandStability(string  $stability) : string

Expand shorthand stability string to long version.

Parameters

string $stability

Returns

string