Prechádzať zdrojové kódy

Add expanding for multiple @notations in one constraint

Jordi Boggiano 12 rokov pred
rodič
commit
0042cebf83
1 zmenil súbory, kde vykonal 11 pridanie a 0 odobranie
  1. 11 0
      src/Packagist/WebBundle/Package/Updater.php

+ 11 - 0
src/Packagist/WebBundle/Package/Updater.php

@@ -284,6 +284,17 @@ class Updater
                     $constraint = preg_replace('{([><=,]) }', '$1', $constraint);
                     $constraint = preg_replace('{(<[0-9.]+)-dev}', '$1', $constraint);
                 }
+
+                if (false !== strpos($constraint, ',') && false !== strpos($constraint, '@')) {
+                    $constraint = preg_replace_callback('{([><]=?\s*[^@]+?)@([a-z]+)}i', function ($matches) {
+                        if ($matches[2] === 'stable') {
+                            return $matches[1];
+                        }
+
+                        return $matches[1].'-'.$matches[2];
+                    }, $constraint);
+                }
+
                 $links[$link->getTarget()] = $constraint;
             }