1 | <?php |
||
18 | class UnknownCommandException extends Exception |
||
19 | { |
||
20 | /** |
||
21 | * @var string the name of the command that could not be recognized. |
||
22 | */ |
||
23 | public $command; |
||
24 | /** |
||
25 | * @var Application |
||
26 | */ |
||
27 | protected $application; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * Construct the exception. |
||
32 | * |
||
33 | * @param string $route the route of the command that could not be found. |
||
34 | * @param Application $application the console application instance involved. |
||
35 | * @param int $code the Exception code. |
||
36 | * @param \Exception $previous the previous exception used for the exception chaining. |
||
37 | */ |
||
38 | 16 | public function __construct($route, $application, $code = 0, \Exception $previous = null) |
|
44 | |||
45 | /** |
||
46 | * @return string the user-friendly name of this exception |
||
47 | */ |
||
48 | 1 | public function getName() |
|
52 | |||
53 | /** |
||
54 | * Suggest alternative commands for [[$command]] based on string similarity. |
||
55 | * |
||
56 | * Alternatives are searched using the following steps: |
||
57 | * |
||
58 | * - suggest alternatives that begin with `$command` |
||
59 | * - find typos by calculating the Levenshtein distance between the unknown command and all |
||
60 | * available commands. The Levenshtein distance is defined as the minimal number of |
||
61 | * characters you have to replace, insert or delete to transform str1 into str2. |
||
62 | * |
||
63 | * @see http://php.net/manual/en/function.levenshtein.php |
||
64 | * @return array a list of suggested alternatives sorted by similarity. |
||
65 | */ |
||
66 | 15 | public function getSuggestedAlternatives() |
|
98 | |||
99 | /** |
||
100 | * Find suggest alternative commands based on string similarity. |
||
101 | * |
||
102 | * Alternatives are searched using the following steps: |
||
103 | * |
||
104 | * - suggest alternatives that begin with `$command` |
||
105 | * - find typos by calculating the Levenshtein distance between the unknown command and all |
||
106 | * available commands. The Levenshtein distance is defined as the minimal number of |
||
107 | * characters you have to replace, insert or delete to transform str1 into str2. |
||
108 | * |
||
109 | * @see http://php.net/manual/en/function.levenshtein.php |
||
110 | * @param array $actions available command names. |
||
111 | * @param string $command the command to compare to. |
||
112 | * @return array a list of suggested alternatives sorted by similarity. |
||
113 | */ |
||
114 | 15 | private function filterBySimilarity($actions, $command) |
|
141 | } |
||
142 |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.