@@ -140,6 +140,6 @@ |
||
| 140 | 140 | */ |
| 141 | 141 | public function addCommander(AbstractCommander $commander) |
| 142 | 142 | { |
| 143 | - $this->commandersPool[ $commander->getCommandName() ] = $commander; |
|
| 143 | + $this->commandersPool[$commander->getCommandName()] = $commander; |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | \ No newline at end of file |
@@ -103,17 +103,17 @@ discard block |
||
| 103 | 103 | $this->commandName = implode('/', array_map('strtolower', explode('/', $className))); |
| 104 | 104 | |
| 105 | 105 | foreach ($this->commandOptions as $optionName => $optionConfig) { |
| 106 | - $shortcut = empty($optionConfig[ 'shortcut' ]) |
|
| 106 | + $shortcut = empty($optionConfig['shortcut']) |
|
| 107 | 107 | ? '-' . substr($optionName, 0, 1) |
| 108 | - : '-' . rtrim($optionConfig[ 'shortcut' ]); |
|
| 108 | + : '-' . rtrim($optionConfig['shortcut']); |
|
| 109 | 109 | |
| 110 | 110 | if (array_key_exists($shortcut, $this->commandOptionsShortcuts)) { |
| 111 | 111 | $shortcut = '-' . substr($optionName, 0, 2); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - $this->commandOptions[ $optionName ][ 'shortcut' ] = $shortcut; |
|
| 114 | + $this->commandOptions[$optionName]['shortcut'] = $shortcut; |
|
| 115 | 115 | |
| 116 | - $this->commandOptionsShortcuts[ $shortcut ] = $optionName; |
|
| 116 | + $this->commandOptionsShortcuts[$shortcut] = $optionName; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | if (array_key_exists('VERBOSE', $_ENV)) { |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | ? '-' . substr($optionName, 0, 1) |
| 159 | 159 | : '-' . rtrim($optionShortcut); |
| 160 | 160 | |
| 161 | - $this->commandOptions[ $optionName ] = [ |
|
| 161 | + $this->commandOptions[$optionName] = [ |
|
| 162 | 162 | 'shortcut' => $optionShortcut, |
| 163 | 163 | 'description' => $optionDescription, |
| 164 | 164 | ]; |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | foreach ($options as $method => $arguments) { |
| 208 | 208 | |
| 209 | 209 | if (array_key_exists('-' . $method, $this->commandOptionsShortcuts)) { |
| 210 | - $method = $this->commandOptionsShortcuts[ '-' . $method ]; |
|
| 210 | + $method = $this->commandOptionsShortcuts['-' . $method]; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | $optionMethod = camelcase('option-' . $method); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | if ($commandMethod->getNumberOfRequiredParameters() == 0) { |
| 220 | 220 | call_user_func([&$this, $optionMethod]); |
| 221 | 221 | } elseif ($commandMethod->getNumberOfRequiredParameters() > 0 and empty($arguments)) { |
| 222 | - if (isset($this->commandOptions[ $method ][ 'help' ])) { |
|
| 222 | + if (isset($this->commandOptions[$method]['help'])) { |
|
| 223 | 223 | output()->write( |
| 224 | 224 | (new Format()) |
| 225 | 225 | ->setContextualClass(Format::INFO) |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | output()->write( |
| 232 | 232 | (new Format()) |
| 233 | 233 | ->setContextualClass(Format::INFO) |
| 234 | - ->setString(language()->getLine($this->commandOptions[ $method ][ 'help' ])) |
|
| 234 | + ->setString(language()->getLine($this->commandOptions[$method]['help'])) |
|
| 235 | 235 | ->setNewLinesAfter(2) |
| 236 | 236 | ); |
| 237 | 237 | } |
@@ -324,8 +324,8 @@ discard block |
||
| 324 | 324 | $table |
| 325 | 325 | ->addRow() |
| 326 | 326 | ->addColumn('--' . $optionCaller) |
| 327 | - ->addColumn($optionProps[ 'shortcut' ]) |
|
| 328 | - ->addColumn(language()->getLine($optionProps[ 'description' ])); |
|
| 327 | + ->addColumn($optionProps['shortcut']) |
|
| 328 | + ->addColumn(language()->getLine($optionProps['description'])); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | output()->write( |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | public function addCommander(AbstractCommander $commander) |
| 375 | 375 | { |
| 376 | - $this->actionsPool[ $commander->getCommandName() ] = $commander; |
|
| 376 | + $this->actionsPool[$commander->getCommandName()] = $commander; |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // ------------------------------------------------------------------------ |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | |
| 61 | 61 | if (property_exists($this, 'contextualClassColorMap')) { |
| 62 | 62 | if (array_key_exists($class, $this->contextualClassColorMap)) { |
| 63 | - $this->setColor(new Color($this->contextualClassColorMap[ $class ])); |
|
| 63 | + $this->setColor(new Color($this->contextualClassColorMap[$class])); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | public function setHeaders(array $headers) |
| 101 | 101 | { |
| 102 | - $this->rows[ self::HEADER_INDEX ] = $headers; |
|
| 102 | + $this->rows[self::HEADER_INDEX] = $headers; |
|
| 103 | 103 | |
| 104 | 104 | return $this; |
| 105 | 105 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | */ |
| 118 | 118 | public function addHeader($content = '') |
| 119 | 119 | { |
| 120 | - $this->rows[ self::HEADER_INDEX ][] = $content; |
|
| 120 | + $this->rows[self::HEADER_INDEX][] = $content; |
|
| 121 | 121 | |
| 122 | 122 | return $this; |
| 123 | 123 | } |
@@ -133,8 +133,8 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public function getHeaders() |
| 135 | 135 | { |
| 136 | - return isset($this->rows[ self::HEADER_INDEX ]) |
|
| 137 | - ? $this->rows[ self::HEADER_INDEX ] |
|
| 136 | + return isset($this->rows[self::HEADER_INDEX]) |
|
| 137 | + ? $this->rows[self::HEADER_INDEX] |
|
| 138 | 138 | : null; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | $this->rowIndex++; |
| 155 | 155 | if (is_array($data)) { |
| 156 | 156 | foreach ($data as $column => $content) { |
| 157 | - $this->rows[ $this->rowIndex ][ $column ] = $content; |
|
| 157 | + $this->rows[$this->rowIndex][$column] = $content; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | ? $this->rowIndex |
| 179 | 179 | : $rowIndex; |
| 180 | 180 | if ($columnIndex === null) { |
| 181 | - $columnIndex = isset($this->rows[ $rowIndex ]) |
|
| 182 | - ? count($this->rows[ $rowIndex ]) |
|
| 181 | + $columnIndex = isset($this->rows[$rowIndex]) |
|
| 182 | + ? count($this->rows[$rowIndex]) |
|
| 183 | 183 | : 0; |
| 184 | 184 | } |
| 185 | - $this->rows[ $rowIndex ][ $columnIndex ] = $content; |
|
| 185 | + $this->rows[$rowIndex][$columnIndex] = $content; |
|
| 186 | 186 | |
| 187 | 187 | return $this; |
| 188 | 188 | } |
@@ -282,11 +282,11 @@ discard block |
||
| 282 | 282 | { |
| 283 | 283 | foreach ($this->rows as $rowIndex => $row) { |
| 284 | 284 | foreach ($row as $columnIndex => $column) { |
| 285 | - if ( ! isset($this->columnWidths[ $columnIndex ])) { |
|
| 286 | - $this->columnWidths[ $columnIndex ] = strlen($column); |
|
| 285 | + if ( ! isset($this->columnWidths[$columnIndex])) { |
|
| 286 | + $this->columnWidths[$columnIndex] = strlen($column); |
|
| 287 | 287 | } else { |
| 288 | - if (strlen($column) > $this->columnWidths[ $columnIndex ]) { |
|
| 289 | - $this->columnWidths[ $columnIndex ] = strlen($column); |
|
| 288 | + if (strlen($column) > $this->columnWidths[$columnIndex]) { |
|
| 289 | + $this->columnWidths[$columnIndex] = strlen($column); |
|
| 290 | 290 | } |
| 291 | 291 | } |
| 292 | 292 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | private function renderBorder() |
| 308 | 308 | { |
| 309 | 309 | $output = ''; |
| 310 | - $columnCount = count($this->rows[ 0 ]); |
|
| 310 | + $columnCount = count($this->rows[0]); |
|
| 311 | 311 | for ($col = 0; $col < $columnCount; $col++) { |
| 312 | 312 | $output .= $this->renderCell($col); |
| 313 | 313 | } |
@@ -334,9 +334,9 @@ discard block |
||
| 334 | 334 | private function renderCell($index, $row = null) |
| 335 | 335 | { |
| 336 | 336 | $cell = $row |
| 337 | - ? $row[ $index ] |
|
| 337 | + ? $row[$index] |
|
| 338 | 338 | : '-'; |
| 339 | - $width = $this->columnWidths[ $index ]; |
|
| 339 | + $width = $this->columnWidths[$index]; |
|
| 340 | 340 | $pad = $row |
| 341 | 341 | ? $width - strlen($cell) |
| 342 | 342 | : $width; |
@@ -153,7 +153,7 @@ |
||
| 153 | 153 | $lines = []; |
| 154 | 154 | |
| 155 | 155 | for ($i = 0; $i < $this->numbers; $i++) { |
| 156 | - $lines[ $i ] = $this->color->paint(str_repeat($this->string, $this->width)); |
|
| 156 | + $lines[$i] = $this->color->paint(str_repeat($this->string, $this->width)); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | return str_repeat(PHP_EOL, $this->newLinesBefore) . implode(PHP_EOL, $lines) . str_repeat(PHP_EOL, |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | return; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - $_POST[ $name ] = $standardInput; |
|
| 60 | + $_POST[$name] = $standardInput; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // ------------------------------------------------------------------------ |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $_POST[ $name ] = (bool)($standardInput === 'Y'); |
|
| 100 | + $_POST[$name] = (bool)($standardInput === 'Y'); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // ------------------------------------------------------------------------ |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | $choices = []; |
| 120 | 120 | $i = 1; |
| 121 | 121 | foreach ($options as $value => $label) { |
| 122 | - $choices[ $i ] = $value; |
|
| 122 | + $choices[$i] = $value; |
|
| 123 | 123 | output()->write( |
| 124 | 124 | (new Format()) |
| 125 | 125 | ->setString('(' . $i . ') ' . language()->getLine($label)) |
@@ -166,6 +166,6 @@ discard block |
||
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $_POST[ $name ] = $choices[ $standardInput ]; |
|
| 169 | + $_POST[$name] = $choices[$standardInput]; |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | \ No newline at end of file |
@@ -161,12 +161,12 @@ |
||
| 161 | 161 | |
| 162 | 162 | // set foreground color |
| 163 | 163 | if (array_key_exists($this->foreground, $this->foregroundColors)) { |
| 164 | - $coloredString .= "\033[" . $this->foregroundColors[ $this->foreground ] . "m"; |
|
| 164 | + $coloredString .= "\033[" . $this->foregroundColors[$this->foreground] . "m"; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // set background color |
| 168 | 168 | if (array_key_exists($this->background, $this->backgroundColors)) { |
| 169 | - $coloredString .= "\033[" . $this->backgroundColors[ $this->background ] . "m"; |
|
| 169 | + $coloredString .= "\033[" . $this->backgroundColors[$this->background] . "m"; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | // combine with string and end the painting |
@@ -93,7 +93,7 @@ |
||
| 93 | 93 | $commander->setApp($this); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $this->commandersPool[ $commander->getCommandName() ] = $commander; |
|
| 96 | + $this->commandersPool[$commander->getCommandName()] = $commander; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // ------------------------------------------------------------------------ |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function parseRequest() |
| 64 | 64 | { |
| 65 | - $argv = $_SERVER[ 'argv' ]; |
|
| 65 | + $argv = $_SERVER['argv']; |
|
| 66 | 66 | |
| 67 | - if ($_SERVER[ 'SCRIPT_NAME' ] === $_SERVER[ 'argv' ][ 0 ]) { |
|
| 67 | + if ($_SERVER['SCRIPT_NAME'] === $_SERVER['argv'][0]) { |
|
| 68 | 68 | array_shift($argv); |
| 69 | 69 | |
| 70 | 70 | if (empty($argv)) { |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $this->string = str_replace(['/', '\\', ':'], '/', $argv[ 0 ]); |
|
| 75 | + $this->string = str_replace(['/', '\\', ':'], '/', $argv[0]); |
|
| 76 | 76 | $this->segments = explode('/', $this->string); |
| 77 | 77 | |
| 78 | - if (strpos($this->segments[ 0 ], '--') !== false |
|
| 79 | - || strpos($this->segments[ 0 ], '-') !== false |
|
| 78 | + if (strpos($this->segments[0], '--') !== false |
|
| 79 | + || strpos($this->segments[0], '-') !== false |
|
| 80 | 80 | ) { |
| 81 | 81 | $options = $this->segments; |
| 82 | 82 | $this->segments = []; |
@@ -95,8 +95,8 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | if (strpos($option, '=') !== false) { |
| 97 | 97 | $optionParts = explode('=', $option); |
| 98 | - $option = $optionParts[ 0 ]; |
|
| 99 | - $value = $optionParts[ 1 ]; |
|
| 98 | + $option = $optionParts[0]; |
|
| 99 | + $value = $optionParts[1]; |
|
| 100 | 100 | } else { |
| 101 | 101 | $value = current($options); |
| 102 | 102 | } |
@@ -110,13 +110,13 @@ discard block |
||
| 110 | 110 | if (strpos($value, '--') === false |
| 111 | 111 | || strpos($value, '-') === false |
| 112 | 112 | ) { |
| 113 | - $_GET[ $option ] = $value; |
|
| 113 | + $_GET[$option] = $value; |
|
| 114 | 114 | } else { |
| 115 | - $_GET[ $option ] = null; |
|
| 115 | + $_GET[$option] = null; |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | 118 | $keys = array_keys($_GET); |
| 119 | - if(count($keys)) { |
|
| 119 | + if (count($keys)) { |
|
| 120 | 120 | $key = end($keys); |
| 121 | 121 | $_GET[$key] = $option; |
| 122 | 122 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | if (array_key_exists('verbose', $_GET) or array_key_exists('v', $_GET)) { |
| 127 | - $_ENV[ 'VERBOSE' ] = true; |
|
| 127 | + $_ENV['VERBOSE'] = true; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | $this->parseSegments($this->segments); |