Documentation

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

Methods

__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
getPrettyString()  : string
getUpperBound()  : Bound
matches()  : bool
Checks whether the given constraint intersects in any way with this constraint
setPrettyString()  : void

Methods

compile()

Provides a compiled version of the constraint for the given operator The compiled version must be a PHP expression.

public compile(int $otherOperator) : string

Executor of compile version must provide 2 variables:

  • $v = the string version to compare with
  • $b = whether or not the version is a non-comparable branch (starts with "dev-")
Parameters
$otherOperator : int

one Constraint::OP_*

Tags
see

Constraint::OP_* for the list of available operators.

example

return '!$b && version_compare($v, '1.0', '>')';

phpstan-param

Constraint::OP_* $otherOperator

Return values
string

setPrettyString()

public setPrettyString(string|null $prettyString) : void
Parameters
$prettyString : string|null

        
On this page

Search results