1
0
Fork 0

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
nevvermind 2015-05-31 15:44:12 +01:00
parent 0ec86be5e9
commit 8c0d4857ef
1 changed files with 1 additions and 2 deletions

View File

@ -31,12 +31,11 @@ class PlatformRepository extends ArrayRepository
*
* @var array
*/
private $overrides;
private $overrides = array();
public function __construct(array $packages = array(), array $overrides = array())
{
parent::__construct($packages);
$this->overrides = array();
foreach ($overrides as $name => $version) {
$this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
}