Documentation

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

Properties

$operator

protected int $operator
Tags
phpstan-var

self::OP_*

$prettyString

protected string|null $prettyString

$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
phpstan-var

array<self::OP_, self::STR_OP_>

$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
phpstan-var

array<self::STR_OP_, self::OP_>

Methods

__construct()

Sets operator and version to compare with.

public __construct(string $operator, string $version) : mixed
Parameters
$operator : string
$version : string
Tags
throws
InvalidArgumentException

if invalid operator is given.

phpstan-param

self::STR_OP_* $operator

__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

getOperator()

public getOperator() : string
Tags
phpstan-return

self::STR_OP_*

Return values
string

getOperatorConstant()

public static getOperatorConstant(string $operator) : int
Parameters
$operator : string
Tags
phpstan-param

self::STR_OP_* $operator

phpstan-return

self::OP_*

Return values
int

getPrettyString()

public getPrettyString() : string
Return values
string

getSupportedOperators()

Get all supported comparison operators.

public static getSupportedOperators() : array<string|int, mixed>
Tags
phpstan-return

listself::STR_OP_*

Return values
array<string|int, mixed>

getVersion()

public getVersion() : string
Return values
string

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

versionCompare()

public versionCompare(string $a, string $b, string $operator[, bool $compareBranches = false ]) : bool
Parameters
$a : string
$b : string
$operator : string
$compareBranches : bool = false
Tags
throws
InvalidArgumentException

if invalid operator is given.

phpstan-param

self::STR_OP_* $operator

Return values
bool

        
On this page

Search results