/usr/share/php/Composer/Package/Version/VersionParser.php is in composer 1.0.0~beta2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Package\Version;
use Composer\Semver\VersionParser as SemverVersionParser;
class VersionParser extends SemverVersionParser
{
private static $constraints = array();
/**
* {@inheritDoc}
*/
public function parseConstraints($constraints)
{
if (!isset(self::$constraints[$constraints])) {
self::$constraints[$constraints] = parent::parseConstraints($constraints);
}
return self::$constraints[$constraints];
}
/**
* Parses an array of strings representing package/version pairs.
*
* The parsing results in an array of arrays, each of which
* contain a 'name' key with value and optionally a 'version' key with value.
*
* @param array $pairs a set of package/version pairs separated by ":", "=" or " "
*
* @return array[] array of arrays containing a name and (if provided) a version
*/
public function parseNameVersionPairs(array $pairs)
{
$pairs = array_values($pairs);
$result = array();
for ($i = 0, $count = count($pairs); $i < $count; $i++) {
$pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/')) {
$pair .= ' '.$pairs[$i + 1];
$i++;
}
if (strpos($pair, ' ')) {
list($name, $version) = explode(" ", $pair, 2);
$result[] = array('name' => $name, 'version' => $version);
} else {
$result[] = array('name' => $pair);
}
}
return $result;
}
}
|