@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @param string $name |
| 186 | 186 | * @param string $description |
| 187 | 187 | * @param mixed $default |
| 188 | - * @return Tarsana\Command\Syntax\SyntaxBuilder |
|
| 188 | + * @return Command |
|
| 189 | 189 | */ |
| 190 | 190 | public function describe($name, $description, $default = null) |
| 191 | 191 | { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * adds/overrides or gets a sub command. |
| 213 | 213 | * |
| 214 | 214 | * @param string $name |
| 215 | - * @param Tarsana\Command\Command|null $cmd |
|
| 215 | + * @param null|Command $cmd |
|
| 216 | 216 | * @return Tarsana\Command\Command |
| 217 | 217 | */ |
| 218 | 218 | public function command ($name, Command $cmd = null) |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * Runs the command. |
| 300 | 300 | * |
| 301 | 301 | * @param string|null $args |
| 302 | - * @param League\CLImate\CLImate|null $console |
|
| 302 | + * @param null|CLImate $console |
|
| 303 | 303 | * @return void |
| 304 | 304 | */ |
| 305 | 305 | public function run ($args = null, CLImate $console = null) |
@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use Tarsana\Functional as F; |
| 6 | 6 | use Tarsana\Functional\Stream; |
| 7 | 7 | use Tarsana\Command\Environment; |
| 8 | -use Tarsana\Syntax\Factory as S; |
|
| 9 | 8 | use Tarsana\Command\TemplateLoader; |
| 10 | 9 | use Tarsana\Command\Commands\HelpCommand; |
| 11 | 10 | use Tarsana\Command\Syntax\SyntaxBuilder; |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | |
| 328 | 328 | else |
| 329 | 329 | $this->args($this->syntax()->parse($args)) |
| 330 | - ->execute(); |
|
| 330 | + ->execute(); |
|
| 331 | 331 | } |
| 332 | 332 | } catch (\Exception $e) { |
| 333 | 333 | $this->error( |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | if (! ($this instanceof HelpCommand) && ! ($this instanceof VersionCommand)) { |
| 379 | 379 | $helpCommand = new HelpCommand($this); |
| 380 | 380 | $this->command('--help', $helpCommand) |
| 381 | - ->command('help', $helpCommand); |
|
| 381 | + ->command('help', $helpCommand); |
|
| 382 | 382 | |
| 383 | 383 | $versionCommand = new VersionCommand($this); |
| 384 | 384 | $this->command('--version', $versionCommand); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * Creates a new Command. |
| 87 | 87 | * |
| 88 | 88 | */ |
| 89 | - public function __construct () |
|
| 89 | + public function __construct() |
|
| 90 | 90 | { |
| 91 | 91 | $this->templateLoader = new TemplateLoader; |
| 92 | 92 | $this->fs = new Filesystem('.'); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @param string|void $value |
| 108 | 108 | * @return string|self |
| 109 | 109 | */ |
| 110 | - public function name ($value = null) |
|
| 110 | + public function name($value = null) |
|
| 111 | 111 | { |
| 112 | 112 | if (null === $value) |
| 113 | 113 | return $this->name; |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param string|void $value |
| 123 | 123 | * @return string|self |
| 124 | 124 | */ |
| 125 | - public function description ($value = null) |
|
| 125 | + public function description($value = null) |
|
| 126 | 126 | { |
| 127 | 127 | if (null === $value) |
| 128 | 128 | return $this->description; |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param string|void $value |
| 138 | 138 | * @return string|self |
| 139 | 139 | */ |
| 140 | - public function version ($value = null) |
|
| 140 | + public function version($value = null) |
|
| 141 | 141 | { |
| 142 | 142 | if (null === $value) |
| 143 | 143 | return $this->version; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param League\CLImate\CLImate|void $value |
| 153 | 153 | * @return League\CLImate\CLImate|self |
| 154 | 154 | */ |
| 155 | - public function console ($value = null) |
|
| 155 | + public function console($value = null) |
|
| 156 | 156 | { |
| 157 | 157 | if (null === $value) |
| 158 | 158 | return $this->console; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @return Tarsana\Syntax\Syntax|self |
| 169 | 169 | * @throws InvalidArgumentException |
| 170 | 170 | */ |
| 171 | - public function syntax ($value = null) |
|
| 171 | + public function syntax($value = null) |
|
| 172 | 172 | { |
| 173 | 173 | if (null === $value) |
| 174 | 174 | return $this->syntaxBuilder->get(); |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @param Tarsana\Command\Command|null $cmd |
| 216 | 216 | * @return Tarsana\Command\Command |
| 217 | 217 | */ |
| 218 | - public function command ($name, Command $cmd = null) |
|
| 218 | + public function command($name, Command $cmd = null) |
|
| 219 | 219 | { |
| 220 | 220 | if (null === $cmd) { |
| 221 | 221 | if (!$this->hasCommand($name)) |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param string $name |
| 234 | 234 | * @return boolean |
| 235 | 235 | */ |
| 236 | - public function hasCommand ($name) { |
|
| 236 | + public function hasCommand($name) { |
|
| 237 | 237 | return isset($this->subCommands[$name]); |
| 238 | 238 | } |
| 239 | 239 | |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * @param League\CLImate\CLImate|null $console |
| 303 | 303 | * @return void |
| 304 | 304 | */ |
| 305 | - public function run ($args = null, CLImate $console = null) |
|
| 305 | + public function run($args = null, CLImate $console = null) |
|
| 306 | 306 | { |
| 307 | 307 | try { |
| 308 | 308 | |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | $this->command($firstArg)->run($args, $console); |
| 318 | 318 | } else { |
| 319 | 319 | $this->console($console); |
| 320 | - if (! $this->syntax()->canParse($args)) { |
|
| 320 | + if (!$this->syntax()->canParse($args)) { |
|
| 321 | 321 | $errors = F\s($this->syntax()->checkParse($args)) |
| 322 | 322 | ->then(F\append("Invalid arguments: '{$args}' for command '{$this->name}'")) |
| 323 | 323 | ->then(F\join(PHP_EOL)) |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @return string |
| 359 | 359 | */ |
| 360 | - protected function consoleArguments () |
|
| 360 | + protected function consoleArguments() |
|
| 361 | 361 | { |
| 362 | 362 | return Stream::of($_SERVER['argv']) // ['script.php', foo', 'lorem ipsum'] |
| 363 | 363 | ->then(F\f('tail')) // ['foo', 'lorem ipsum'] |
@@ -373,9 +373,9 @@ discard block |
||
| 373 | 373 | /** |
| 374 | 374 | * Adds Help and Version sub commands. |
| 375 | 375 | */ |
| 376 | - protected function addDefaultSubCommands () |
|
| 376 | + protected function addDefaultSubCommands() |
|
| 377 | 377 | { |
| 378 | - if (! ($this instanceof HelpCommand) && ! ($this instanceof VersionCommand)) { |
|
| 378 | + if (!($this instanceof HelpCommand) && !($this instanceof VersionCommand)) { |
|
| 379 | 379 | $helpCommand = new HelpCommand($this); |
| 380 | 380 | $this->command('--help', $helpCommand) |
| 381 | 381 | ->command('help', $helpCommand); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * @param string $message |
| 392 | 392 | * @return void |
| 393 | 393 | */ |
| 394 | - protected function error ($message) |
|
| 394 | + protected function error($message) |
|
| 395 | 395 | { |
| 396 | 396 | $this->console->style->addCommand('error', 'white'); |
| 397 | 397 | $this->console->backgroundRed()->error($message); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param CLImate $console |
| 407 | 407 | * @return void |
| 408 | 408 | */ |
| 409 | - protected function call ($name, $args = null, CLImate $console = null) |
|
| 409 | + protected function call($name, $args = null, CLImate $console = null) |
|
| 410 | 410 | { |
| 411 | 411 | return Environment::get() |
| 412 | 412 | ->command($name) |
@@ -420,12 +420,12 @@ discard block |
||
| 420 | 420 | * |
| 421 | 421 | * @return void |
| 422 | 422 | */ |
| 423 | - protected function init () {} |
|
| 423 | + protected function init() {} |
|
| 424 | 424 | |
| 425 | 425 | /** |
| 426 | 426 | * The logic of the command goes in this method. |
| 427 | 427 | * |
| 428 | 428 | * @return self |
| 429 | 429 | */ |
| 430 | - abstract protected function execute (); |
|
| 430 | + abstract protected function execute(); |
|
| 431 | 431 | } |
@@ -109,8 +109,9 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function name ($value = null) |
| 111 | 111 | { |
| 112 | - if (null === $value) |
|
| 113 | - return $this->name; |
|
| 112 | + if (null === $value) { |
|
| 113 | + return $this->name; |
|
| 114 | + } |
|
| 114 | 115 | |
| 115 | 116 | $this->name = $value; |
| 116 | 117 | return $this; |
@@ -124,8 +125,9 @@ discard block |
||
| 124 | 125 | */ |
| 125 | 126 | public function description ($value = null) |
| 126 | 127 | { |
| 127 | - if (null === $value) |
|
| 128 | - return $this->description; |
|
| 128 | + if (null === $value) { |
|
| 129 | + return $this->description; |
|
| 130 | + } |
|
| 129 | 131 | |
| 130 | 132 | $this->description = $value; |
| 131 | 133 | return $this; |
@@ -139,8 +141,9 @@ discard block |
||
| 139 | 141 | */ |
| 140 | 142 | public function version ($value = null) |
| 141 | 143 | { |
| 142 | - if (null === $value) |
|
| 143 | - return $this->version; |
|
| 144 | + if (null === $value) { |
|
| 145 | + return $this->version; |
|
| 146 | + } |
|
| 144 | 147 | |
| 145 | 148 | $this->version = $value; |
| 146 | 149 | return $this; |
@@ -154,8 +157,9 @@ discard block |
||
| 154 | 157 | */ |
| 155 | 158 | public function console ($value = null) |
| 156 | 159 | { |
| 157 | - if (null === $value) |
|
| 158 | - return $this->console; |
|
| 160 | + if (null === $value) { |
|
| 161 | + return $this->console; |
|
| 162 | + } |
|
| 159 | 163 | |
| 160 | 164 | $this->console = $value; |
| 161 | 165 | return $this; |
@@ -170,8 +174,9 @@ discard block |
||
| 170 | 174 | */ |
| 171 | 175 | public function syntax ($value = null) |
| 172 | 176 | { |
| 173 | - if (null === $value) |
|
| 174 | - return $this->syntaxBuilder->get(); |
|
| 177 | + if (null === $value) { |
|
| 178 | + return $this->syntaxBuilder->get(); |
|
| 179 | + } |
|
| 175 | 180 | |
| 176 | 181 | $this->syntaxBuilder = SyntaxBuilder::of($value); |
| 177 | 182 | |
@@ -218,8 +223,9 @@ discard block |
||
| 218 | 223 | public function command ($name, Command $cmd = null) |
| 219 | 224 | { |
| 220 | 225 | if (null === $cmd) { |
| 221 | - if (!$this->hasCommand($name)) |
|
| 222 | - throw new CommandNotFound("Command '{$name}' not found"); |
|
| 226 | + if (!$this->hasCommand($name)) { |
|
| 227 | + throw new CommandNotFound("Command '{$name}' not found"); |
|
| 228 | + } |
|
| 223 | 229 | return $this->subCommands[$name]; |
| 224 | 230 | } |
| 225 | 231 | |
@@ -245,8 +251,9 @@ discard block |
||
| 245 | 251 | */ |
| 246 | 252 | public function args($value = null) |
| 247 | 253 | { |
| 248 | - if (null === $value) |
|
| 249 | - return $this->args; |
|
| 254 | + if (null === $value) { |
|
| 255 | + return $this->args; |
|
| 256 | + } |
|
| 250 | 257 | |
| 251 | 258 | $this->args = $value; |
| 252 | 259 | return $this; |
@@ -306,10 +313,12 @@ discard block |
||
| 306 | 313 | { |
| 307 | 314 | try { |
| 308 | 315 | |
| 309 | - if (null === $args) |
|
| 310 | - $args = $this->consoleArguments(); |
|
| 311 | - if (null === $console) |
|
| 312 | - $console = new CLImate; |
|
| 316 | + if (null === $args) { |
|
| 317 | + $args = $this->consoleArguments(); |
|
| 318 | + } |
|
| 319 | + if (null === $console) { |
|
| 320 | + $console = new CLImate; |
|
| 321 | + } |
|
| 313 | 322 | |
| 314 | 323 | $firstArg = F\head(F\split(' ', $args)); |
| 315 | 324 | if ($this->hasCommand($firstArg)) { |
@@ -323,11 +332,10 @@ discard block |
||
| 323 | 332 | ->then(F\join(PHP_EOL)) |
| 324 | 333 | ->get(); |
| 325 | 334 | $this->error($errors); |
| 326 | - } |
|
| 327 | - |
|
| 328 | - else |
|
| 329 | - $this->args($this->syntax()->parse($args)) |
|
| 335 | + } else { |
|
| 336 | + $this->args($this->syntax()->parse($args)) |
|
| 330 | 337 | ->execute(); |
| 338 | + } |
|
| 331 | 339 | } |
| 332 | 340 | } catch (\Exception $e) { |
| 333 | 341 | $this->error( |
@@ -346,8 +354,9 @@ discard block |
||
| 346 | 354 | */ |
| 347 | 355 | protected function template($name) |
| 348 | 356 | { |
| 349 | - if (null === $this->templateLoader) |
|
| 350 | - throw new NullPropertyAccess("The templatesLoader is not initialized; Please set it before trying to load a template !"); |
|
| 357 | + if (null === $this->templateLoader) { |
|
| 358 | + throw new NullPropertyAccess("The templatesLoader is not initialized; Please set it before trying to load a template !"); |
|
| 359 | + } |
|
| 351 | 360 | |
| 352 | 361 | return $this->templateLoader->load($name); |
| 353 | 362 | } |
@@ -74,6 +74,9 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | + /** |
|
| 78 | + * @param integer $level |
|
| 79 | + */ |
|
| 77 | 80 | protected function showSyntax($name, $syntax, $level) |
| 78 | 81 | { |
| 79 | 82 | $type = $this->typeOf($syntax); |
@@ -102,6 +105,9 @@ discard block |
||
| 102 | 105 | } |
| 103 | 106 | } |
| 104 | 107 | |
| 108 | + /** |
|
| 109 | + * @return integer |
|
| 110 | + */ |
|
| 105 | 111 | protected function typeOf(Syntax $syntax) |
| 106 | 112 | { |
| 107 | 113 | if ($syntax instanceof ObjectSyntax) { |
@@ -5,9 +5,7 @@ |
||
| 5 | 5 | use Tarsana\Functional as F; |
| 6 | 6 | use Tarsana\Command\SubCommand; |
| 7 | 7 | use Tarsana\Syntax\ArraySyntax; |
| 8 | -use Tarsana\Syntax\Factory as S; |
|
| 9 | 8 | use Tarsana\Syntax\ObjectSyntax; |
| 10 | -use Tarsana\Command\Syntax\SyntaxPrinter; |
|
| 11 | 9 | |
| 12 | 10 | |
| 13 | 11 | class HelpCommand extends SubCommand { |
@@ -35,15 +35,15 @@ discard block |
||
| 35 | 35 | $c = $this->console(); |
| 36 | 36 | |
| 37 | 37 | $c->br() |
| 38 | - ->green() |
|
| 39 | - ->inline($command->name() . ' ') |
|
| 40 | - ->yellow() |
|
| 41 | - ->out($command->version()) |
|
| 42 | - ->br() |
|
| 43 | - ->out($command->description()) |
|
| 44 | - ->br() |
|
| 45 | - ->yellow() |
|
| 46 | - ->inline('Arguments: '); |
|
| 38 | + ->green() |
|
| 39 | + ->inline($command->name() . ' ') |
|
| 40 | + ->yellow() |
|
| 41 | + ->out($command->version()) |
|
| 42 | + ->br() |
|
| 43 | + ->out($command->description()) |
|
| 44 | + ->br() |
|
| 45 | + ->yellow() |
|
| 46 | + ->inline('Arguments: '); |
|
| 47 | 47 | |
| 48 | 48 | $args = F\s(array_keys($command->syntax()->fields())) |
| 49 | 49 | ->then(F\join(' ')) |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | ->get() * 2; |
| 68 | 68 | foreach ($command->subCommands() as $name => $cmd) { |
| 69 | 69 | $c->tab() |
| 70 | - ->padding($padding)->char(' ') |
|
| 71 | - ->label("<green>{$name}</green>") |
|
| 72 | - ->result($cmd->description()); |
|
| 70 | + ->padding($padding)->char(' ') |
|
| 71 | + ->label("<green>{$name}</green>") |
|
| 72 | + ->result($cmd->description()); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | $c->out("(Required)"); |
| 87 | 87 | } else { |
| 88 | 88 | $c->inline("(default: ") |
| 89 | - ->white()->inline(json_encode($syntax->getDefault())) |
|
| 90 | - ->yellow()->out(" )"); |
|
| 89 | + ->white()->inline(json_encode($syntax->getDefault())) |
|
| 90 | + ->yellow()->out(" )"); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | if ($syntax instanceof ArraySyntax) { |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class HelpCommand extends SubCommand { |
| 14 | 14 | |
| 15 | - protected function init () |
|
| 15 | + protected function init() |
|
| 16 | 16 | { |
| 17 | 17 | $this |
| 18 | 18 | ->name('Help') |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | ->syntax('[command]'); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - protected function execute () |
|
| 24 | + protected function execute() |
|
| 25 | 25 | { |
| 26 | 26 | $command = trim($this->args->command); |
| 27 | 27 | if (empty($command) || !$this->parent()->hasCommand($command)) |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | $this->showHelpOf($this->parent->command($command)); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - protected function showHelpOf (Command $command) |
|
| 33 | + protected function showHelpOf(Command $command) |
|
| 34 | 34 | { |
| 35 | 35 | $c = $this->console(); |
| 36 | 36 | |
@@ -24,10 +24,11 @@ |
||
| 24 | 24 | protected function execute () |
| 25 | 25 | { |
| 26 | 26 | $command = trim($this->args->command); |
| 27 | - if (empty($command) || !$this->parent()->hasCommand($command)) |
|
| 28 | - $this->showHelpOf($this->parent); |
|
| 29 | - else |
|
| 30 | - $this->showHelpOf($this->parent->command($command)); |
|
| 27 | + if (empty($command) || !$this->parent()->hasCommand($command)) { |
|
| 28 | + $this->showHelpOf($this->parent); |
|
| 29 | + } else { |
|
| 30 | + $this->showHelpOf($this->parent->command($command)); |
|
| 31 | + } |
|
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | protected function showHelpOf (Command $command) |
@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php namespace Tarsana\Command; |
| 2 | 2 | |
| 3 | 3 | use Tarsana\Command\Command; |
| 4 | -use Tarsana\Command\Commands\HelpCommand; |
|
| 5 | 4 | |
| 6 | 5 | /** |
| 7 | 6 | * A SubCommand which has a parent command and can access it. |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * A constructor alias; If you don't like the 'new' keyword. |
| 25 | 25 | * @param string|Tarsana\Syntax\ObjectSyntax $syntax |
| 26 | - * @return Tarsana\Command\Syntax\SyntaxBuilder |
|
| 26 | + * @return SyntaxBuilder |
|
| 27 | 27 | * @throws Tarsana\Command\Exceptions\SyntaxBuilderException |
| 28 | 28 | */ |
| 29 | 29 | public static function of($syntax) |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @param string $name |
| 89 | 89 | * @param string $description |
| 90 | 90 | * @param mixed $default |
| 91 | - * @return Tarsana\Command\Syntax\SyntaxBuilder |
|
| 91 | + * @return SyntaxBuilder |
|
| 92 | 92 | */ |
| 93 | 93 | public function describe($name, $description, $default = null) |
| 94 | 94 | { |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | /** |
| 105 | 105 | * Gets a field or subfield from an Syntax. |
| 106 | 106 | * |
| 107 | - * @param Tarsana\Syntax\Syntax $syntax |
|
| 107 | + * @param Syntax $syntax |
|
| 108 | 108 | * @param array $names |
| 109 | 109 | * @return Tarsana\Syntax\Syntax |
| 110 | 110 | * @throws Tarsana\Command\Exceptions\SyntaxBuilderException |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * Ensures that `$syntax` is an ObjectSyntax or an ArraySyntax of ObjectSyntaxes, |
| 123 | 123 | * and returns the ObjectSyntax or throws a SyntaxBuilderException. |
| 124 | 124 | * |
| 125 | - * @param Tarsana\Syntax\Syntax $syntax |
|
| 126 | - * @return Tarsana\Syntax\Syntax |
|
| 125 | + * @param Syntax $syntax |
|
| 126 | + * @return ObjectSyntax |
|
| 127 | 127 | * @throws Tarsana\Command\Exceptions\SyntaxBuilderException |
| 128 | 128 | */ |
| 129 | 129 | protected function ensureObject(Syntax $syntax) |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | if (is_string($syntax)) { |
| 43 | 43 | $syntax = self::syntaxFromString($syntax); |
| 44 | - } else if (! ($syntax instanceof ObjectSyntax)) { |
|
| 44 | + } else if (!($syntax instanceof ObjectSyntax)) { |
|
| 45 | 45 | throw new SyntaxBuilderException("The command syntax should be an insatnce of ObjectSyntax"); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | * @return Tarsana\Syntax\Syntax |
| 66 | 66 | * @throws Tarsana\Command\Exceptions\SyntaxBuilderException |
| 67 | 67 | */ |
| 68 | - protected static function syntaxFromString ($value) |
|
| 68 | + protected static function syntaxFromString($value) |
|
| 69 | 69 | { |
| 70 | 70 | $syntax = F\s($value)->then( // "first name" [#age] |
| 71 | - F\chunks('(){}[]""', ' '), // ["first name", [#age]] |
|
| 72 | - F\join(','), // "first name",[#age] |
|
| 71 | + F\chunks('(){}[]""', ' '), // ["first name", [#age]] |
|
| 72 | + F\join(','), // "first name",[#age] |
|
| 73 | 73 | F\prepend('{ ,'), F\append('}') // { ,"first name",[#age]} |
| 74 | 74 | )->get(); |
| 75 | 75 | |
@@ -111,8 +111,7 @@ discard block |
||
| 111 | 111 | */ |
| 112 | 112 | protected function field(Syntax $syntax, $names) |
| 113 | 113 | { |
| 114 | - return empty($names) ? $syntax : |
|
| 115 | - $this->field( |
|
| 114 | + return empty($names) ? $syntax : $this->field( |
|
| 116 | 115 | $this->ensureObject($syntax)->field(F\head($names)), |
| 117 | 116 | F\tail($names) |
| 118 | 117 | ); |
@@ -131,7 +130,7 @@ discard block |
||
| 131 | 130 | while ($syntax instanceof ArraySyntax) { |
| 132 | 131 | $syntax = $syntax->itemSyntax(); |
| 133 | 132 | } |
| 134 | - if (! ($syntax instanceof ObjectSyntax)) { |
|
| 133 | + if (!($syntax instanceof ObjectSyntax)) { |
|
| 135 | 134 | throw new SyntaxBuilderException("Could not retreive field of non object syntax '{$syntax}'"); |
| 136 | 135 | } |
| 137 | 136 | return $syntax; |
@@ -75,8 +75,9 @@ |
||
| 75 | 75 | |
| 76 | 76 | $ss = S::syntax(); |
| 77 | 77 | |
| 78 | - if (!$ss->canParse($syntax)) |
|
| 79 | - throw new SyntaxBuilderException("Invalid Syntax: '{$syntax}'"); |
|
| 78 | + if (!$ss->canParse($syntax)) { |
|
| 79 | + throw new SyntaxBuilderException("Invalid Syntax: '{$syntax}'"); |
|
| 80 | + } |
|
| 80 | 81 | |
| 81 | 82 | return $ss->parse($syntax); |
| 82 | 83 | } |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | /** |
| 59 | 59 | * Filesystem getter and setter. |
| 60 | 60 | * |
| 61 | - * @param Tarsana\IO\Filesystem|void $value |
|
| 61 | + * @param null|Filesystem $value |
|
| 62 | 62 | * @return Tarsana\IO\Filesystem|self |
| 63 | 63 | */ |
| 64 | 64 | public function fs (Filesystem $value = null) |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param Tarsana\IO\Filesystem|void $value |
| 62 | 62 | * @return Tarsana\IO\Filesystem|self |
| 63 | 63 | */ |
| 64 | - public function fs (Filesystem $value = null) |
|
| 64 | + public function fs(Filesystem $value = null) |
|
| 65 | 65 | { |
| 66 | 66 | if (null === $value) |
| 67 | 67 | return $this->fs; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @throws Tarsana\Command\Exceptions\TemplateNotFound |
| 82 | 82 | * @throws Tarsana\Command\Exceptions\TemplateNameConflict |
| 83 | 83 | */ |
| 84 | - public function load ($name) |
|
| 84 | + public function load($name) |
|
| 85 | 85 | { |
| 86 | 86 | $suportedExtensions = array_keys(self::$providers); |
| 87 | 87 | |
@@ -63,8 +63,9 @@ |
||
| 63 | 63 | */ |
| 64 | 64 | public function fs (Filesystem $value = null) |
| 65 | 65 | { |
| 66 | - if (null === $value) |
|
| 67 | - return $this->fs; |
|
| 66 | + if (null === $value) { |
|
| 67 | + return $this->fs; |
|
| 68 | + } |
|
| 68 | 69 | $this->fs = $value; |
| 69 | 70 | return $this; |
| 70 | 71 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | * Loads a template. |
| 39 | 39 | * |
| 40 | 40 | * @param string $name |
| 41 | - * @return Tarsana\Command\Templates\TwigTemplate |
|
| 41 | + * @return TwigTemplate |
|
| 42 | 42 | */ |
| 43 | 43 | public function load($name) |
| 44 | 44 | { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | protected $data; |
| 23 | 23 | |
| 24 | - public function __construct (\Twig_TemplateInterface $twig) |
|
| 24 | + public function __construct(\Twig_TemplateInterface $twig) |
|
| 25 | 25 | { |
| 26 | 26 | $this->twig = $twig; |
| 27 | 27 | $this->data = []; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $data |
| 34 | 34 | * @return self |
| 35 | 35 | */ |
| 36 | - public function bind ($data) |
|
| 36 | + public function bind($data) |
|
| 37 | 37 | { |
| 38 | 38 | $this->data = array_merge($this->data, $data); |
| 39 | 39 | return $this; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return self |
| 59 | 59 | */ |
| 60 | - public function clean () |
|
| 60 | + public function clean() |
|
| 61 | 61 | { |
| 62 | 62 | $this->data = []; |
| 63 | 63 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | public function command($name, $value = null) |
| 74 | 74 | { |
| 75 | 75 | if (null === $value) { |
| 76 | - if (! $this->hasCommand($name)) { |
|
| 76 | + if (!$this->hasCommand($name)) { |
|
| 77 | 77 | throw new EnvironmentException("Unable to find the command '{$name}'"); |
| 78 | 78 | } |
| 79 | 79 | return $this->store->get($name); |
@@ -19,8 +19,8 @@ |
||
| 19 | 19 | { |
| 20 | 20 | $c = $this->parent(); |
| 21 | 21 | $this->console |
| 22 | - ->green()->inline($c->name()) |
|
| 23 | - ->white()->inline(' version ') |
|
| 24 | - ->yellow()->out($c->version()); |
|
| 22 | + ->green()->inline($c->name()) |
|
| 23 | + ->white()->inline(' version ') |
|
| 24 | + ->yellow()->out($c->version()); |
|
| 25 | 25 | } |
| 26 | 26 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | class VersionCommand extends SubCommand { |
| 9 | 9 | |
| 10 | - protected function init () |
|
| 10 | + protected function init() |
|
| 11 | 11 | { |
| 12 | 12 | $this |
| 13 | 13 | ->name('Version') |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | ->description('Shows the version of the command'); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - protected function execute () |
|
| 18 | + protected function execute() |
|
| 19 | 19 | { |
| 20 | 20 | $c = $this->parent(); |
| 21 | 21 | $this->console |