Skip to content

Commit

Permalink
Improve readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 17, 2017
1 parent 4ef784d commit e663e82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Console/CommandCollection.php
Expand Up @@ -66,6 +66,7 @@ public function add($name, $command)
"Cannot use '$class' for command '$name' it is not a subclass of Cake\Console\Shell."
);
}

$this->commands[$name] = $command;

return $this;
Expand Down Expand Up @@ -176,6 +177,7 @@ public function autoDiscover()
if (empty($shells[$key])) {
return $out;
}

foreach ($shells[$key] as $info) {
$name = $info['name'];
$addLong = $name !== $info['fullName'];
Expand Down
6 changes: 5 additions & 1 deletion src/Console/CommandScanner.php
Expand Up @@ -29,7 +29,7 @@
class CommandScanner
{
/**
* Scan the application, cakephp and plugins for shells
* Scan CakePHP core, the applications and plugins for shell classes
*
* @return array
*/
Expand All @@ -51,6 +51,7 @@ public function scanAll()
'',
['command_list']
);

$plugins = [];
foreach (Plugin::loaded() as $plugin) {
$plugins[$plugin] = $this->scanDir(
Expand Down Expand Up @@ -82,16 +83,19 @@ protected function scanDir($path, $namespace, $prefix, array $hide)
if (empty($contents[1])) {
return [];
}

$shells = [];
foreach ($contents[1] as $file) {
if (substr($file, -4) !== '.php') {
continue;
}

$shell = substr($file, 0, -4);
$name = Inflector::underscore(str_replace('Shell', '', $shell));
if (in_array($name, $hide, true)) {
continue;
}

$shells[] = [
'file' => $path . $file,
'fullName' => $prefix . $name,
Expand Down

0 comments on commit e663e82

Please sign in to comment.