From 530991217baeccc7537ed4ac3164361a7dea8eaf Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 25 Nov 2012 12:08:41 +0100 Subject: [PATCH] Support classmap generation for classes without space after class name Class names with multi-byte characters are not supported. Closes #1360. --- src/Composer/Autoload/ClassMapGenerator.php | 2 +- tests/Composer/Test/Autoload/ClassMapGeneratorTest.php | 6 +++--- .../Test/Autoload/Fixtures/classmap/MissingSpace.php | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 tests/Composer/Test/Autoload/Fixtures/classmap/MissingSpace.php diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 378ad47a3..427d3342e 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -125,7 +125,7 @@ class ClassMapGenerator preg_match_all('{ (?: - \b(?])(?class|interface'.$traits.') \s+ (?\S+) + \b(?])(?class|interface'.$traits.') \s+ (?\w+) | \b(?])(?namespace) (?\s+[^\s;{}\\\\]+(?:\s*\\\\\s*[^\s;{}\\\\]+)*)? \s*[\{;] ) }ix', $contents, $matches); diff --git a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php index cbdadec2d..3856247de 100644 --- a/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php +++ b/tests/Composer/Test/Autoload/ClassMapGeneratorTest.php @@ -30,8 +30,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase 'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php', 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php', 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php', - ) - ), + )), array(__DIR__.'/Fixtures/beta/NamespaceCollision', array( 'NamespaceCollision\\A\\B\\Bar' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Bar.php', 'NamespaceCollision\\A\\B\\Foo' => realpath(__DIR__).'/Fixtures/beta/NamespaceCollision/A/B/Foo.php', @@ -53,7 +52,8 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase 'ClassMap\\SomeParent' => realpath(__DIR__).'/Fixtures/classmap/SomeParent.php', 'ClassMap\\SomeClass' => realpath(__DIR__).'/Fixtures/classmap/SomeClass.php', 'Foo\\LargeClass' => realpath(__DIR__).'/Fixtures/classmap/LargeClass.php', - 'Foo\\LargeGap' => realpath(__DIR__).'/Fixtures/classmap/LargeGap.php', + 'Foo\\LargeGap' => realpath(__DIR__).'/Fixtures/classmap/LargeGap.php', + 'Foo\\MissingSpace' => realpath(__DIR__).'/Fixtures/classmap/MissingSpace.php', )), array(__DIR__.'/Fixtures/template', array()), ); diff --git a/tests/Composer/Test/Autoload/Fixtures/classmap/MissingSpace.php b/tests/Composer/Test/Autoload/Fixtures/classmap/MissingSpace.php new file mode 100644 index 000000000..2b646371c --- /dev/null +++ b/tests/Composer/Test/Autoload/Fixtures/classmap/MissingSpace.php @@ -0,0 +1,6 @@ +