Skip to content

Commit

Permalink
Don't use pass by ref variables.
Browse files Browse the repository at this point in the history
I don't much care for pass by ref when there are simpler ways to write
the required code.
  • Loading branch information
markstory committed Aug 16, 2014
1 parent 65cacbc commit 3c00ea4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Console/Command/Task/CommandTask.php
Expand Up @@ -44,17 +44,17 @@ public function getShellList() {
$corePath = App::core('Console/Command');
$shells = $this->_scanDir($corePath[0]);
$shells = array_diff($shells, $skipFiles, $hiddenCommands);
$this->_appendShells('CORE', $shells, $shellList);
$shellList = $this->_appendShells('CORE', $shells, $shellList);

$appPath = App::path('Console/Command');
$appShells = $this->_scanDir($appPath[0]);
$appShells = array_diff($appShells, $shells, $skipFiles);
$this->_appendShells('app', $appShells, $shellList);
$shellList = $this->_appendShells('app', $appShells, $shellList);

foreach ($plugins as $plugin) {
$pluginPath = Plugin::classPath($plugin) . 'Console' . DS . 'Command';
$pluginShells = $this->_scanDir($pluginPath);
$this->_appendShells($plugin, $pluginShells, $shellList);
$shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
}

return array_filter($shellList);
Expand All @@ -65,13 +65,14 @@ public function getShellList() {
*
* @param string $type The type of object.
* @param array $shells The shell name.
* @param array &$shellList List of shells.
* @return void
* @param array $shellList List of shells.
* @return array The updated $shellList
*/
protected function _appendShells($type, $shells, &$shellList) {
protected function _appendShells($type, $shells, $shellList) {
foreach ($shells as $shell) {
$shellList[$type][] = Inflector::underscore(str_replace('Shell', '', $shell));
}
return $shellList;
}

/**
Expand Down

0 comments on commit 3c00ea4

Please sign in to comment.