From a531594a4adf938dc0063650c24d005760b86f29 Mon Sep 17 00:00:00 2001 From: Michael Gusev Date: Sun, 16 Nov 2014 14:24:44 +0100 Subject: [PATCH] Issue #3422 https://github.com/composer/composer/issues/3422 --- src/Composer/Autoload/ClassLoader.php | 5 ++++- tests/Composer/Test/Autoload/ClassLoaderTest.php | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index 443364959..4a56396af 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -56,7 +56,10 @@ class ClassLoader public function getPrefixes() { - return call_user_func_array('array_merge', $this->prefixesPsr0); + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + return array(); } public function getPrefixesPsr4() diff --git a/tests/Composer/Test/Autoload/ClassLoaderTest.php b/tests/Composer/Test/Autoload/ClassLoaderTest.php index ad42e233a..50772101e 100644 --- a/tests/Composer/Test/Autoload/ClassLoaderTest.php +++ b/tests/Composer/Test/Autoload/ClassLoaderTest.php @@ -55,4 +55,13 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase array('ShinyVendor\\ShinyPackage\\SubNamespace\\Bar', true), ); } + + /** + * getPrefixes method should return empty array if ClassLoader does not have any psr-0 configuration + */ + public function testGetPrefixesWithNoPSR0Configuration() + { + $loader = new ClassLoader(); + $this->assertEmpty($loader->getPrefixes()); + } }