Documentation

Intervals
in package

Helper class generating intervals from constraints

This contains utilities for:

  • compacting an existing constraint which can be used to combine several into one by creating a MultiConstraint out of the many constraints you have.

  • checking whether one subset is a subset of another.

Note: You should call clear to free memoization memory usage when you are done using this class

Table of Contents

$intervalsCache  : mixed
$opSortOrder  : mixed
clear()  : void
Clears the memoization cache once you are done
compactConstraint()  : ConstraintInterface
Attempts to optimize a MultiConstraint
get()  : array<string|int, mixed>
Creates an array of numeric intervals and branch constraints representing a given constraint
haveIntersections()  : bool
Checks whether $a and $b have any intersection, equivalent to $a->matches($b)
isSubsetOf()  : bool
Checks whether $candidate is a subset of $constraint
generateIntervals()  : mixed
generateSingleConstraintIntervals()  : mixed

Properties

$intervalsCache

private static mixed $intervalsCache = array()
Tags
phpstan-var

array<string, array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}>

$opSortOrder

private static mixed $opSortOrder = array('>=' => -3, '<' => -2, '>' => 2, '<=' => 3)
Tags
phpstan-var

array<string, int>

Methods

clear()

Clears the memoization cache once you are done

public static clear() : void
Return values
void

compactConstraint()

Attempts to optimize a MultiConstraint

public static compactConstraint(ConstraintInterface $constraint) : ConstraintInterface

When merging MultiConstraints together they can get very large, this will compact it by looking at the real intervals covered by all the constraints and then creates a new constraint containing only the smallest amount of rules to match the same intervals.

Parameters
$constraint : ConstraintInterface
Return values
ConstraintInterface

get()

Creates an array of numeric intervals and branch constraints representing a given constraint

public static get(ConstraintInterface $constraint) : array<string|int, mixed>

if the returned numeric array is empty it means the constraint matches nothing in the numeric range (0 - +inf) if the returned branches array is empty it means no dev-* versions are matched if a constraint matches all possible dev-* versions, branches will contain Interval::anyDev()

Parameters
$constraint : ConstraintInterface
Tags
phpstan-return

array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}

Return values
array<string|int, mixed>

generateIntervals()

private static generateIntervals(ConstraintInterface $constraint[, bool $stopOnFirstValidInterval = false ]) : mixed
Parameters
$constraint : ConstraintInterface
$stopOnFirstValidInterval : bool = false
Tags
phpstan-return

array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}

Return values
mixed

generateSingleConstraintIntervals()

private static generateSingleConstraintIntervals(Constraint $constraint) : mixed
Parameters
$constraint : Constraint
Tags
phpstan-return

array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}}

Return values
mixed

Search results