Переглянути джерело

Add support for .inc files in classmap, fixes #1396

Jordi Boggiano 12 роки тому
батько
коміт
aefe3a0b11

+ 2 - 1
doc/04-schema.md

@@ -416,7 +416,8 @@ use an empty prefix like:
 
 
 The `classmap` references are all combined, during install/update, into a single
 The `classmap` references are all combined, during install/update, into a single
 key => value array which may be found in the generated file
 key => value array which may be found in the generated file
-`vendor/composer/autoload_classmap.php`.
+`vendor/composer/autoload_classmap.php`. This map is built by scanning for
+classes in all `.php` and `.inc` files in the given directories/files.
 
 
 You can use the classmap generation support to define autoloading for all libraries
 You can use the classmap generation support to define autoloading for all libraries
 that do not follow PSR-0. To configure this you specify all directories or files
 that do not follow PSR-0. To configure this you specify all directories or files

+ 1 - 1
src/Composer/Autoload/ClassMapGenerator.php

@@ -71,7 +71,7 @@ class ClassMapGenerator
 
 
             $filePath = $file->getRealPath();
             $filePath = $file->getRealPath();
 
 
-            if (pathinfo($filePath, PATHINFO_EXTENSION) !== 'php') {
+            if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc'))) {
                 continue;
                 continue;
             }
             }
 
 

+ 1 - 1
tests/Composer/Test/Autoload/ClassMapGeneratorTest.php

@@ -27,7 +27,7 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
     {
     {
         $data = array(
         $data = array(
             array(__DIR__.'/Fixtures/Namespaced', array(
             array(__DIR__.'/Fixtures/Namespaced', array(
-                'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.php',
+                'Namespaced\\Bar' => realpath(__DIR__).'/Fixtures/Namespaced/Bar.inc',
                 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
                 'Namespaced\\Foo' => realpath(__DIR__).'/Fixtures/Namespaced/Foo.php',
                 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
                 'Namespaced\\Baz' => realpath(__DIR__).'/Fixtures/Namespaced/Baz.php',
             )),
             )),

+ 0 - 0
tests/Composer/Test/Autoload/Fixtures/Namespaced/Bar.php → tests/Composer/Test/Autoload/Fixtures/Namespaced/Bar.inc