1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Joomla! Statistics Server |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (C) 2013 - 2017 Open Source Matters, Inc. All rights reserved. |
6
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License Version 2 or Later |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Joomla\StatsServer\Commands; |
10
|
|
|
|
11
|
|
|
use Joomla\Application\Cli\ColorStyle; |
12
|
|
|
use Joomla\Application\Cli\Output\Processor\ColorProcessor; |
13
|
|
|
use Joomla\Controller\AbstractController; |
14
|
|
|
use Joomla\StatsServer\CommandInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Help command |
18
|
|
|
* |
19
|
|
|
* @method \Joomla\StatsServer\CliApplication getApplication() Get the application object. |
20
|
|
|
* @property-read \Joomla\StatsServer\CliApplication $app Application object |
21
|
|
|
*/ |
22
|
|
|
class HelpCommand extends AbstractController implements CommandInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Execute the controller. |
26
|
|
|
* |
27
|
|
|
* @return boolean |
28
|
|
|
*/ |
29
|
|
|
public function execute() |
30
|
|
|
{ |
31
|
|
|
/** @var ColorProcessor $processor */ |
32
|
|
|
$processor = $this->getApplication()->getOutput()->getProcessor(); |
33
|
|
|
$processor->addStyle('cmd', new ColorStyle('magenta')); |
34
|
|
|
|
35
|
|
|
$executable = basename($this->getApplication()->input->executable); |
36
|
|
|
|
37
|
|
|
$commands = $this->getApplication()->getConsole()->getCommands(); |
|
|
|
|
38
|
|
|
|
39
|
|
|
$this->getApplication()->outputTitle($this->getTitle()); |
40
|
|
|
|
41
|
|
|
$this->getApplication()->out( |
42
|
|
|
sprintf('Usage: <info>%s</info> <cmd><command></cmd>', |
43
|
|
|
$executable |
44
|
|
|
) |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
$this->getApplication()->out() |
48
|
|
|
->out('Available commands:') |
49
|
|
|
->out(); |
50
|
|
|
|
51
|
|
|
foreach ($this->getApplication()->getConsole()->getCommands() as $cName => $command) |
52
|
|
|
{ |
53
|
|
|
$this->getApplication()->out('<cmd>' . $cName . '</cmd>'); |
54
|
|
|
|
55
|
|
|
if ($command->getDescription()) |
56
|
|
|
{ |
57
|
|
|
$this->getApplication()->out(' ' . $command->getDescription()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$this->getApplication()->out(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return true; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Get the command's description |
68
|
|
|
* |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getDescription() : string |
72
|
|
|
{ |
73
|
|
|
return 'Provides basic use information for the stats application.'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Get the command's title |
78
|
|
|
* |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public function getTitle() : string |
82
|
|
|
{ |
83
|
|
|
return 'Joomla Stats Application'; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.