فهرست منبع

PHP 5.3 does not support $this in closures. Nested reuse of identical variables separated.

Niels Keurentjes 9 سال پیش
والد
کامیت
98845dca6f
2فایلهای تغییر یافته به همراه10 افزوده شده و 8 حذف شده
  1. 6 4
      src/Composer/Config/JsonConfigSource.php
  2. 4 4
      src/Composer/Package/Loader/RootPackageLoader.php

+ 6 - 4
src/Composer/Config/JsonConfigSource.php

@@ -79,10 +79,11 @@ class JsonConfigSource implements ConfigSourceInterface
      */
     public function addConfigSetting($name, $value)
     {
-        $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) {
+        $that = $this;
+        $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($that) {
             if (preg_match('{^(github-oauth|gitlab-oauth|http-basic|platform)\.}', $key)) {
                 list($key, $host) = explode('.', $key, 2);
-                if ($this->authConfig) {
+                if ($that->authConfig) {
                     $config[$key][$host] = $val;
                 } else {
                     $config['config'][$key][$host] = $val;
@@ -98,10 +99,11 @@ class JsonConfigSource implements ConfigSourceInterface
      */
     public function removeConfigSetting($name)
     {
-        $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) {
+        $that = $this;
+        $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($that) {
             if (preg_match('{^(github-oauth|gitlab-oauth|http-basic|platform)\.}', $key)) {
                 list($key, $host) = explode('.', $key, 2);
-                if ($this->authConfig) {
+                if ($that->authConfig) {
                     unset($config[$key][$host]);
                 } else {
                     unset($config['config'][$key][$host]);

+ 4 - 4
src/Composer/Package/Loader/RootPackageLoader.php

@@ -175,10 +175,10 @@ class RootPackageLoader extends ArrayLoader
 
             // extract all sub-constraints in case it is an OR/AND multi-constraint
             $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
-            foreach ($orSplit as $constraint) {
-                $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraint);
-                foreach ($andSplit as $constraint) {
-                    $constraints[] = $constraint;
+            foreach ($orSplit as $orConstraint) {
+                $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
+                foreach ($andSplit as $andConstraint) {
+                    $constraints[] = $andConstraint;
                 }
             }