Fix "Invalid argument supplied for foreach()" on a new PlaformRepository obj
This happens on "new PlatformRepository(array($somePackage))". The parent constructor calls "\Composer\Repository\ArrayRepository::addPackage()", which, on a brand new repo object, further calls "\Composer\Repository\PlatformRepository::initialize()" and finally this iterates over a NULLd "$this->overrides", triggering the error.pull/4088/head
parent
0ec86be5e9
commit
8c0d4857ef
|
@ -31,12 +31,11 @@ class PlatformRepository extends ArrayRepository
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $overrides;
|
private $overrides = array();
|
||||||
|
|
||||||
public function __construct(array $packages = array(), array $overrides = array())
|
public function __construct(array $packages = array(), array $overrides = array())
|
||||||
{
|
{
|
||||||
parent::__construct($packages);
|
parent::__construct($packages);
|
||||||
$this->overrides = array();
|
|
||||||
foreach ($overrides as $name => $version) {
|
foreach ($overrides as $name => $version) {
|
||||||
$this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
|
$this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue