From 98845dca6f2dc03bb2390a758813046b5f02c2e7 Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Sat, 27 Feb 2016 22:45:44 +0100 Subject: [PATCH] PHP 5.3 does not support $this in closures. Nested reuse of identical variables separated. --- src/Composer/Config/JsonConfigSource.php | 10 ++++++---- src/Composer/Package/Loader/RootPackageLoader.php | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index 8e5a6036e..1eeaee6f4 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/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]); diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index 959d3c17f..18a551748 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/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('{(?< ,]) *(?< ,]) *(?