|
1 | 1 | <?php |
2 | 2 |
|
3 | | -/* |
4 | | - +------------------------------------------------------------------------+ |
5 | | - | Phalcon Cli option parser | |
6 | | - +------------------------------------------------------------------------+ |
7 | | - | Copyright (c) 2011-present Phalcon Team (https://www.phalconphp.com) | |
8 | | - +------------------------------------------------------------------------+ |
9 | | - | This source file is subject to the New BSD License that is bundled | |
10 | | - | with this package in the file LICENSE.txt. | |
11 | | - | | |
12 | | - | If you did not receive a copy of the license and are unable to | |
13 | | - | obtain it through the world-wide-web, please send an email | |
14 | | - | to license@phalconphp.com so we can send you a copy immediately. | |
15 | | - +------------------------------------------------------------------------+ |
16 | | - | Authors: Sergii Svyrydenko <sergey.v.sviridenko@gmail.com> | |
17 | | - +------------------------------------------------------------------------+ |
18 | | -*/ |
| 3 | +/** |
| 4 | + * This file is part of the Cop package. |
| 5 | + * |
| 6 | + * (c) Phalcon Team <team@phalconphp.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
19 | 11 |
|
20 | 12 | namespace Phalcon\Cop; |
21 | 13 |
|
@@ -44,16 +36,17 @@ class Parser |
44 | 36 | ]; |
45 | 37 |
|
46 | 38 | /** |
47 | | - * Parse CLI command |
| 39 | + * Parse console input. |
48 | 40 | * |
49 | | - * @param array $argv |
| 41 | + * @param array $argv |
50 | 42 | * @return array |
51 | 43 | */ |
52 | 44 | public function parse(array $argv = []): array |
53 | 45 | { |
54 | 46 | if (empty($argv)) { |
55 | 47 | $argv = $this->getArgvFromServer(); |
56 | 48 | } |
| 49 | + |
57 | 50 | array_shift($argv); |
58 | 51 | $this->parsedCommands = []; |
59 | 52 |
|
@@ -81,18 +74,13 @@ public function getBoolean(string $key, bool $default = false): bool |
81 | 74 | } |
82 | 75 |
|
83 | 76 | /** |
84 | | - * Get console command either from argument or from Server |
| 77 | + * Gets array of arguments passed from the input. |
85 | 78 | * |
86 | 79 | * @return array |
87 | | - * @throws Exception |
88 | 80 | */ |
89 | 81 | protected function getArgvFromServer(): array |
90 | 82 | { |
91 | | - if (!empty($_SERVER['argv'])) { |
92 | | - return $_SERVER['argv']; |
93 | | - } |
94 | | - |
95 | | - throw new Exception("Parameters haven't been defined yet"); |
| 83 | + return empty($_SERVER['argv']) ? [] : $_SERVER['argv']; |
96 | 84 | } |
97 | 85 |
|
98 | 86 | /** |
|
0 commit comments