Browse Source

Fix error handling for incorrect "repositories" array

Dmitry Tarasov 10 years ago
parent
commit
3b678ee379
2 changed files with 13 additions and 1 deletions
  1. 1 1
      src/Composer/Config.php
  2. 12 0
      tests/Composer/Test/ConfigTest.php

+ 1 - 1
src/Composer/Config.php

@@ -124,7 +124,7 @@ class Config
                 }
 
                 // disable a repository with an anonymous {"name": false} repo
-                if (1 === count($repository) && false === current($repository)) {
+                if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
                     unset($this->repositories[key($repository)]);
                     continue;
                 }

+ 12 - 0
tests/Composer/Test/ConfigTest.php

@@ -97,6 +97,18 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
             ),
         );
 
+        $data['incorrect local config does not cause ErrorException'] = array(
+            array(
+                'packagist' => array('type' => 'composer', 'url' => 'https?://packagist.org', 'allow_ssl_downgrade' => true),
+                'type' => 'vcs',
+                'url' => 'http://example.com',
+            ),
+            array(
+                'type' => 'vcs',
+                'url' => 'http://example.com',
+            ),
+        );
+
         return $data;
     }