*/ class StabilityFlags { /** @var array Current package name => stability mappings */ protected $stabilityFlags; /** @var int Current default minimum stability */ protected $minimumStability; /** @var string Regex to extract an explicit stability flag (eg '@dev') */ protected $explicitStabilityRe; /** * @param array $stabilityFlags Current package name => stability mappings * @param int|string $minimumStability Current default minimum stability */ public function __construct(array $stabilityFlags = [], $minimumStability = BasePackage::STABILITY_STABLE) { $this->stabilityFlags = $stabilityFlags; $this->minimumStability = $this->getStabilityInt((string)$minimumStability); $this->explicitStabilityRe = '/^[^@]*?@(' . implode('|', array_keys(BasePackage::$stabilities)) . ')$/i'; } /** * Get the stability value for a given string. * * @param string $name Stability name * @return int Stability value */ protected function getStabilityInt($name) { $name = VersionParser::normalizeStability($name); return BasePackage::$stabilities[$name] ?? BasePackage::STABILITY_STABLE; } /** * Extract and merge stability flags from the given collection of * requires with another collection of stability flags. * * @param array $requires New package name => link mappings * @return array Unified package name => stability mappings */ public function extractAll(array $requires) { $flags = []; foreach ($requires as $name => $link) { $name = strtolower($name); $version = $link->getPrettyConstraint(); $stability = $this->getExplicitStability($version); if ($stability === null) { $stability = $this->getParsedStability($version); } $flags[$name] = max($stability, $this->getCurrentStability($name)); } // Filter out null stability values return array_filter($flags, function ($v) { return $v !== null; }); } /** * Extract the most unstable explicit stability (eg '@dev') from a version * specification. * * @param string $version * @return int|null Stability or null if no explict stability found */ protected function getExplicitStability($version) { $found = null; $constraints = $this->splitConstraints($version); foreach ($constraints as $constraint) { if (preg_match($this->explicitStabilityRe, $constraint, $match)) { $stability = $this->getStabilityInt($match[1]); $found = max($stability, $found); } } return $found; } /** * Split a version specification into a list of version constraints. * * @param string $version * @return array */ protected function splitConstraints($version) { $found = []; $orConstraints = preg_split('/\s*\|\|?\s*/', trim($version)); foreach ($orConstraints as $constraints) { $andConstraints = preg_split( '/(?< ,]) *(?getStabilityInt( VersionParser::parseStability($version) ); if ($stability === BasePackage::STABILITY_STABLE || $this->minimumStability > $stability ) { // Ignore if 'stable' or more stable than the global // minimum $stability = null; } return $stability; } /** * Get the current stability of a given package. * * @param string $name * @return int|null Stability of null if not set */ protected function getCurrentStability($name) { return $this->stabilityFlags[$name] ?? null; } } __halt_compiler();----SIGNATURE:----k1Ck39or27SFi5oE57R1B57fwC3ISJCgS5xdsG1xbJsVC4XL2gxSVk53uEcd+HkMkcGuWle9AgffuRSodTHTjMD/sL06vQXc9nm+vdFS1xPQpWvfbmK2m+UGmEGVNbrmntbJo17hb+mk8q8TCytl6iDx3Zwz5zKh8Addjr9vxoHzvqI2LEE0PT/kxA48nnxYjqueuaijGcBhJ5KAD5l8GsLGV1+NYmi8q2kTEGJzvX9BalCbnK25PUUcmeuvZo403HZrE0BDVRenpb0GIHgFponAeLIhDY0kCBnct9iOC0cb273F3F/mGjpVMLtvH1E9riYztXWg2/+OiypQKCQNO/ALnkKXj/Ru+0f8gobAT1dCaVazjt9x6n6xeiEFjBzZHdhs8oC3/rb1mC6aJ71uky3ppVRwNmzTj1lyvw+WTgefxKbY1u3iBd6bs9apfWBrnQAcJK+HS6Djuz5uStAHtqoK+y0IzOPngFNc8UBLDH3jPQSWg8ufATnCjjiAuUPfTHittCHeE3LZ5yF10NoyKlK1HKVBfS/ZLhhRrRINa12FYC5lLiqHny4Y5Nii+M+W1sZgxttcYsm/wOu4gCtlK8L5all0nMktEXwLsuJu3/urh6mxvEIMaiRn5Na86gszrT6QSeSzp6eMohcuY89K2J829lelu6lzpZzibd4Au88=----ATTACHMENT:----MTQ4OTg3MTMyNjA2NjgyMSAyNjkwNDg5OTc3MzQxMjY2IDQ0MDIzMDE1OTEyOTA2OTY=