Constraint
in package
implements
ConstraintInterface
Defines a constraint.
Table of Contents
Interfaces
- ConstraintInterface
- DO NOT IMPLEMENT this interface. It is only meant for usage as a type hint in libraries relying on composer/semver but creating your own constraint class that implements this interface is not a supported use case and will cause the composer/semver components to return unexpected results.
Constants
- OP_EQ = 0
- OP_GE = 4
- OP_GT = 3
- OP_LE = 2
- OP_LT = 1
- OP_NE = 5
- STR_OP_EQ = '=='
- STR_OP_EQ_ALT = '='
- STR_OP_GE = '>='
- STR_OP_GT = '>'
- STR_OP_LE = '<='
- STR_OP_LT = '<'
- STR_OP_NE = '!='
- STR_OP_NE_ALT = '<>'
Properties
- $lowerBound : Bound
- $operator : int
- $prettyString : string|null
- $upperBound : Bound
- $version : string
- $transOpInt : array<string|int, mixed>
- Integer to operator translation table.
- $transOpStr : array<string|int, mixed>
- Operator to integer translation table.
Methods
- __construct() : mixed
- Sets operator and version to compare with.
- __toString() : string
- compile() : string
- Provides a compiled version of the constraint for the given operator The compiled version must be a PHP expression.
- getLowerBound() : Bound
- getOperator() : string
- getOperatorConstant() : int
- getPrettyString() : string
- getSupportedOperators() : array<string|int, mixed>
- Get all supported comparison operators.
- getUpperBound() : Bound
- getVersion() : string
- matches() : bool
- Checks whether the given constraint intersects in any way with this constraint
- matchSpecific() : bool
- setPrettyString() : void
- versionCompare() : bool
- extractBounds() : void
Constants
OP_EQ
public
mixed
OP_EQ
= 0
OP_GE
public
mixed
OP_GE
= 4
OP_GT
public
mixed
OP_GT
= 3
OP_LE
public
mixed
OP_LE
= 2
OP_LT
public
mixed
OP_LT
= 1
OP_NE
public
mixed
OP_NE
= 5
STR_OP_EQ
public
mixed
STR_OP_EQ
= '=='
STR_OP_EQ_ALT
public
mixed
STR_OP_EQ_ALT
= '='
STR_OP_GE
public
mixed
STR_OP_GE
= '>='
STR_OP_GT
public
mixed
STR_OP_GT
= '>'
STR_OP_LE
public
mixed
STR_OP_LE
= '<='
STR_OP_LT
public
mixed
STR_OP_LT
= '<'
STR_OP_NE
public
mixed
STR_OP_NE
= '!='
STR_OP_NE_ALT
public
mixed
STR_OP_NE_ALT
= '<>'
Properties
$lowerBound
protected
Bound
$lowerBound
$operator
protected
int
$operator
Tags
$prettyString
protected
string|null
$prettyString
$upperBound
protected
Bound
$upperBound
$version
protected
string
$version
$transOpInt
Integer to operator translation table.
private
static array<string|int, mixed>
$transOpInt
= array(self::OP_EQ => '==', self::OP_LT => '<', self::OP_LE => '<=', self::OP_GT => '>', self::OP_GE => '>=', self::OP_NE => '!=')
Tags
$transOpStr
Operator to integer translation table.
private
static array<string|int, mixed>
$transOpStr
= array('=' => self::OP_EQ, '==' => self::OP_EQ, '<' => self::OP_LT, '<=' => self::OP_LE, '>' => self::OP_GT, '>=' => self::OP_GE, '<>' => self::OP_NE, '!=' => self::OP_NE)
Tags
Methods
__construct()
Sets operator and version to compare with.
public
__construct(string $operator, string $version) : mixed
Parameters
- $operator : string
- $version : string
Tags
__toString()
public
__toString() : string
Return values
stringcompile()
Provides a compiled version of the constraint for the given operator The compiled version must be a PHP expression.
public
compile(mixed $otherOperator) : string
Parameters
- $otherOperator : mixed
-
one Constraint::OP_*
Return values
stringgetLowerBound()
public
getLowerBound() : Bound
Return values
BoundgetOperator()
public
getOperator() : string
Tags
Return values
stringgetOperatorConstant()
public
static getOperatorConstant(string $operator) : int
Parameters
- $operator : string
Tags
Return values
intgetPrettyString()
public
getPrettyString() : string
Return values
stringgetSupportedOperators()
Get all supported comparison operators.
public
static getSupportedOperators() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getUpperBound()
public
getUpperBound() : Bound
Return values
BoundgetVersion()
public
getVersion() : string
Return values
stringmatches()
Checks whether the given constraint intersects in any way with this constraint
public
matches(ConstraintInterface $provider) : bool
Parameters
- $provider : ConstraintInterface
Return values
boolmatchSpecific()
public
matchSpecific(Constraint $provider[, bool $compareBranches = false ]) : bool
Parameters
- $provider : Constraint
- $compareBranches : bool = false
Return values
boolsetPrettyString()
public
setPrettyString(mixed $prettyString) : void
Parameters
- $prettyString : mixed
versionCompare()
public
versionCompare(string $a, string $b, string $operator[, bool $compareBranches = false ]) : bool
Parameters
- $a : string
- $b : string
- $operator : string
- $compareBranches : bool = false
Tags
Return values
boolextractBounds()
private
extractBounds() : void