You are here

protected function StabilityFlags::splitConstraints in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/wikimedia/composer-merge-plugin/src/Merge/StabilityFlags.php \Wikimedia\Composer\Merge\StabilityFlags::splitConstraints()

Split a version specification into a list of version constraints.

Parameters

string $version:

Return value

array

1 call to StabilityFlags::splitConstraints()
StabilityFlags::getExplicitStability in vendor/wikimedia/composer-merge-plugin/src/Merge/StabilityFlags.php
Extract the most unstable explicit stability (eg '@dev') from a version specification.

File

vendor/wikimedia/composer-merge-plugin/src/Merge/StabilityFlags.php, line 126

Class

StabilityFlags
Adapted from Composer's RootPackageLoader::extractStabilityFlags @author Bryan Davis <bd808@bd808.com>

Namespace

Wikimedia\Composer\Merge

Code

protected function splitConstraints($version) {
  $found = array();
  $orConstraints = preg_split('/\\s*\\|\\|?\\s*/', trim($version));
  foreach ($orConstraints as $constraints) {
    $andConstraints = preg_split('/(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)/', $constraints);
    foreach ($andConstraints as $constraint) {
      $found[] = $constraint;
    }
  }
  return $found;
}