瀏覽代碼

Merge pull request #7477 from staabm/patch-1

GLOB_BRACE is not defined on all platforms
Rob 6 年之前
父節點
當前提交
b44c9acae6
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      src/Composer/Repository/PathRepository.php

+ 9 - 1
src/Composer/Repository/PathRepository.php

@@ -174,9 +174,17 @@ class PathRepository extends ArrayRepository implements ConfigurableRepositoryIn
      */
     private function getUrlMatches()
     {
+        $flags = GLOB_MARK | GLOB_ONLYDIR;
+        
+        if (defined('GLOB_BRACE')) {
+            $flags |= GLOB_BRACE;
+        } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
+            throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
+        }
+        
         // Ensure environment-specific path separators are normalized to URL separators
         return array_map(function ($val) {
             return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
-        }, glob($this->url, GLOB_MARK | GLOB_ONLYDIR | GLOB_BRACE));
+        }, glob($this->url, $flags));
     }
 }