Browse Source

Add psr-4 stuff in a few more places.

Andreas Hennings 11 years ago
parent
commit
39c09d5192

+ 4 - 0
doc/04-schema.md

@@ -438,6 +438,10 @@ use an empty prefix like:
         }
     }
 
+#### PSR-4
+
+Stub: Similar to PSR-0.
+
 #### Classmap
 
 The `classmap` references are all combined, during install/update, into a single

+ 5 - 0
res/composer-schema.json

@@ -203,6 +203,11 @@
                     "description": "This is a hash of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
                     "additionalProperties": true
                 },
+                "psr-4": {
+                    "type": "object",
+                    "description": "This is a hash of namespaces (keys) and the PSR-4 directories they can be found into (values, can be arrays of paths) by the autoloader.",
+                    "additionalProperties": true
+                },
                 "classmap": {
                     "type": "array",
                     "description": "This is an array of directories that contain classes to be included in the class-map generation process."

+ 6 - 0
src/Composer/Autoload/AutoloadGenerator.php

@@ -310,6 +310,12 @@ EOF;
             }
         }
 
+        if (isset($autoloads['psr-4'])) {
+            foreach ($autoloads['psr-4'] as $namespace => $path) {
+                $loader->addPsr4($namespace, $path);
+            }
+        }
+
         return $loader;
     }
 

+ 4 - 0
src/Composer/Command/ShowCommand.php

@@ -303,6 +303,10 @@ EOT
                     foreach ($autoloads as $name => $path) {
                         $output->writeln(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
                     }
+                } elseif ($type === 'psr-4') {
+                    foreach ($autoloads as $name => $path) {
+                        $output->writeln(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
+                    }
                 } elseif ($type === 'classmap') {
                     $output->writeln(implode(', ', $autoloads));
                 }

+ 1 - 1
src/Composer/Package/Loader/ValidatingArrayLoader.php

@@ -180,7 +180,7 @@ class ValidatingArrayLoader implements LoaderInterface
         }
 
         if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
-            $types = array('psr-0', 'classmap', 'files');
+            $types = array('psr-0', 'psr-4', 'classmap', 'files');
             foreach ($this->config['autoload'] as $type => $typeConfig) {
                 if (!in_array($type, $types)) {
                     $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);