Documentation

MultiConstraint
in package
implements ConstraintInterface

Defines a conjunctive or disjunctive set of constraints.

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

$conjunctive  : bool
$constraints  : array<string|int, ConstraintInterface>
$lowerBound  : Bound|null
$prettyString  : string|null
$string  : string|null
$upperBound  : Bound|null
__construct()  : mixed
__toString()  : string
compile()  : string
Provides a compiled version of the constraint for the given operator The compiled version must be a PHP expression.
create()  : ConstraintInterface
Tries to optimize the constraints as much as possible, meaning reducing/collapsing congruent constraints etc.
getConstraints()  : array<string|int, ConstraintInterface>
getLowerBound()  : Bound
getPrettyString()  : string
getUpperBound()  : Bound
isConjunctive()  : bool
isDisjunctive()  : bool
matches()  : bool
Checks whether the given constraint intersects in any way with this constraint
setPrettyString()  : void
extractBounds()  : void
optimizeConstraints()  : array<string|int, mixed>|null

Properties

Methods

__construct()

public __construct(array<string|int, ConstraintInterface$constraints[, bool $conjunctive = true ]) : mixed
Parameters
$constraints : array<string|int, ConstraintInterface>

A set of constraints

$conjunctive : bool = true

Whether the constraints should be treated as conjunctive or disjunctive

Tags
throws
InvalidArgumentException

If less than 2 constraints are passed

Return values
mixed

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

create()

Tries to optimize the constraints as much as possible, meaning reducing/collapsing congruent constraints etc.

public static create(array<string|int, ConstraintInterface$constraints[, bool $conjunctive = true ]) : ConstraintInterface

Does not necessarily return a MultiConstraint instance if things can be reduced to a simple constraint

Parameters
$constraints : array<string|int, ConstraintInterface>

A set of constraints

$conjunctive : bool = true

Whether the constraints should be treated as conjunctive or disjunctive

Return values
ConstraintInterface

getPrettyString()

public getPrettyString() : string
Return values
string

isConjunctive()

public isConjunctive() : bool
Return values
bool

isDisjunctive()

public isDisjunctive() : bool
Return values
bool

setPrettyString()

public setPrettyString(mixed $prettyString) : void
Parameters
$prettyString : mixed
Return values
void

extractBounds()

private extractBounds() : void
Return values
void

optimizeConstraints()

private static optimizeConstraints(array<string|int, ConstraintInterface$constraints, bool $conjunctive) : array<string|int, mixed>|null
Parameters
$constraints : array<string|int, ConstraintInterface>
$conjunctive : bool
Tags
phpstan-return

array{0: list, 1: bool}|null

Return values
array<string|int, mixed>|null

Search results