Constraint
in package
implements
ConstraintInterface
Defines a constraint.
Interfaces, Classes and Traits
- 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.
Table of Contents
- 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 = '<>'
- $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.
- __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
= ""
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
Return values
mixed —__toString()
public
__toString() : string
Return values
string —compile()
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
string —getLowerBound()
public
getLowerBound() : Bound
Return values
Bound —getOperator()
public
getOperator() : string
Tags
Return values
string —getOperatorConstant()
public
static getOperatorConstant(string $operator) : int
Parameters
- $operator : string
Tags
Return values
int —getPrettyString()
public
getPrettyString() : string
Return values
string —getSupportedOperators()
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
Bound —getVersion()
public
getVersion() : string
Return values
string —matches()
Checks whether the given constraint intersects in any way with this constraint
public
matches(ConstraintInterface $provider) : bool
Parameters
- $provider : ConstraintInterface
Return values
bool —matchSpecific()
public
matchSpecific(Constraint $provider[, bool $compareBranches = false ]) : bool
Parameters
- $provider : Constraint
- $compareBranches : bool = false
Return values
bool —setPrettyString()
public
setPrettyString(mixed $prettyString) : void
Parameters
- $prettyString : mixed
Return values
void —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
bool —extractBounds()
private
extractBounds() : void