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

main
Niels Keurentjes 8 years ago
parent 868e607f17
commit 98845dca6f

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

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

Loading…
Cancel
Save