Fixed #2601, the callback functions expect param 1 to be a reference to the $config
parent
60bf5633ea
commit
6bdcd9266c
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue