Skip to content

Commit

Permalink
Add psr-4 stuff in a few more places.
Browse files Browse the repository at this point in the history
  • Loading branch information
donquixote committed Dec 14, 2013
1 parent b62fa2b commit 39c09d5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/04-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions res/composer-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
6 changes: 6 additions & 0 deletions src/Composer/Autoload/AutoloadGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ public function createLoader(array $autoloads)
}
}

if (isset($autoloads['psr-4'])) {
foreach ($autoloads['psr-4'] as $namespace => $path) {
$loader->addPsr4($namespace, $path);
}
}

return $loader;
}

Expand Down
4 changes: 4 additions & 0 deletions src/Composer/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ protected function printMeta(InputInterface $input, OutputInterface $output, Com
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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/Composer/Package/Loader/ValidatingArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function load(array $config, $class = 'Composer\Package\CompletePackage')
}

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);
Expand Down

0 comments on commit 39c09d5

Please sign in to comment.