Copied!

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

Cloneable Instantiable
Methods
public static clear ()
 

Clears the memoization cache once you are done

  • return void
public static compactConstraint ( Composer\Semver\Constraint\ConstraintInterface $constraint )
 

Attempts to optimize a MultiConstraint

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.

  • return ConstraintInterface
public static get ( Composer\Semver\Constraint\ConstraintInterface $constraint )
 

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

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()

  • return array
  • phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
public static haveIntersections ( Composer\Semver\Constraint\ConstraintInterface $a , Composer\Semver\Constraint\ConstraintInterface $b )
 

Checks whether $a and $b have any intersection, equivalent to $a->matches($b)

  • return bool
public static isSubsetOf ( Composer\Semver\Constraint\ConstraintInterface $candidate , Composer\Semver\Constraint\ConstraintInterface $constraint )
 

Checks whether $candidate is a subset of $constraint

  • return bool
Properties
private static $intervalsCache
 
  • phpstan-var array
private static $opSortOrder = [ '>=' => -3 , '<' => -2 , '>' => 2 , '<=' => 3 ]
 
  • phpstan-var array
Methods
private static generateIntervals ( Composer\Semver\Constraint\ConstraintInterface $constraint , $stopOnFirstValidInterval = false )
 
  • param bool $stopOnFirstValidInterval
  • phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
private static generateSingleConstraintIntervals ( Composer\Semver\Constraint\Constraint $constraint )
 
  • phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
Properties
private static $intervalsCache
 
  • phpstan-var array
private static $opSortOrder = [ '>=' => -3 , '<' => -2 , '>' => 2 , '<=' => 3 ]
 
  • phpstan-var array
Methods
public static clear ()
 

Clears the memoization cache once you are done

  • return void
public static compactConstraint ( Composer\Semver\Constraint\ConstraintInterface $constraint )
 

Attempts to optimize a MultiConstraint

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.

  • return ConstraintInterface
private static generateIntervals ( Composer\Semver\Constraint\ConstraintInterface $constraint , $stopOnFirstValidInterval = false )
 
  • param bool $stopOnFirstValidInterval
  • phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
private static generateSingleConstraintIntervals ( Composer\Semver\Constraint\Constraint $constraint )
 
  • phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
public static get ( Composer\Semver\Constraint\ConstraintInterface $constraint )
 

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

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()

  • return array
  • phpstan-return array{'numeric': Interval[], 'branches': array{'names': string[], 'exclude': bool}}
public static haveIntersections ( Composer\Semver\Constraint\ConstraintInterface $a , Composer\Semver\Constraint\ConstraintInterface $b )
 

Checks whether $a and $b have any intersection, equivalent to $a->matches($b)

  • return bool
public static isSubsetOf ( Composer\Semver\Constraint\ConstraintInterface $candidate , Composer\Semver\Constraint\ConstraintInterface $constraint )
 

Checks whether $candidate is a subset of $constraint

  • return bool
© 2022 Bruce Wells
Search Namespaces \ Classes
Configuration