1
0
Fork 0

Fixed #2601, the callback functions expect param 1 to be a reference to the $config

pull/2720/merge
Sandy Pleyte 2014-02-18 10:38:13 +01:00 committed by Jordi Boggiano
parent 60bf5633ea
commit 6bdcd9266c
1 changed files with 18 additions and 2 deletions

View File

@ -23,8 +23,10 @@ use Composer\Json\JsonManipulator;
*/
class JsonConfigSource implements ConfigSourceInterface
{
/**
* @var \Composer\Json\JsonFile
*/
private $file;
private $manipulator;
/**
* Constructor
@ -118,7 +120,7 @@ class JsonConfigSource implements ConfigSourceInterface
} else {
// on failed clean update, call the fallback and rewrite the whole file
$config = $this->file->read();
array_unshift($args, $config);
$this->array_unshift_ref($args, $config);
call_user_func_array($fallback, $args);
$this->file->write($config);
}
@ -127,4 +129,18 @@ class JsonConfigSource implements ConfigSourceInterface
@chmod($this->file->getPath(), 0600);
}
}
/**
* Prepend a reference to an element to the beginning of an array.
*
* @param array $array array
* @param mixed $value mixed
* @return array
*/
function array_unshift_ref(&$array, &$value)
{
$return = array_unshift($array, '');
$array[0] =& $value;
return $return;
}
}