@@ -64,6 +64,9 @@ |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param Command $command |
|
| 69 | + */ |
|
| 67 | 70 | public function findAndAddHookOptions($command) |
| 68 | 71 | { |
| 69 | 72 | if (!$command instanceof AnnotatedCommand) { |
@@ -2,17 +2,10 @@ |
||
| 2 | 2 | namespace Consolidation\AnnotatedCommand; |
| 3 | 3 | |
| 4 | 4 | use Symfony\Component\Console\Command\Command; |
| 5 | -use Symfony\Component\Console\Input\InputInterface; |
|
| 6 | -use Symfony\Component\Console\Output\OutputInterface; |
|
| 7 | - |
|
| 8 | 5 | use Symfony\Component\Console\Application; |
| 9 | 6 | use Symfony\Component\Console\ConsoleEvents; |
| 10 | 7 | use Symfony\Component\Console\Event\ConsoleCommandEvent; |
| 11 | 8 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
| 12 | - |
|
| 13 | -use Consolidation\AnnotatedCommand\ExitCodeInterface; |
|
| 14 | -use Consolidation\AnnotatedCommand\OutputDataInterface; |
|
| 15 | -use Consolidation\AnnotatedCommand\AnnotationData; |
|
| 16 | 9 | use Consolidation\AnnotatedCommand\AnnotatedCommand; |
| 17 | 10 | |
| 18 | 11 | /** |
@@ -58,8 +58,7 @@ |
||
| 58 | 58 | $nameOfCommandToDescribe = $event->getInput()->getArgument('command_name'); |
| 59 | 59 | $commandToDescribe = $this->application->find($nameOfCommandToDescribe); |
| 60 | 60 | $this->findAndAddHookOptions($commandToDescribe); |
| 61 | - } |
|
| 62 | - else { |
|
| 61 | + } else { |
|
| 63 | 62 | $this->findAndAddHookOptions($command); |
| 64 | 63 | } |
| 65 | 64 | } |
@@ -35,6 +35,9 @@ discard block |
||
| 35 | 35 | protected $usesOutputInterface; |
| 36 | 36 | protected $returnType; |
| 37 | 37 | |
| 38 | + /** |
|
| 39 | + * @param string $name |
|
| 40 | + */ |
|
| 38 | 41 | public function __construct($name = null) |
| 39 | 42 | { |
| 40 | 43 | $commandInfo = false; |
@@ -63,6 +66,9 @@ discard block |
||
| 63 | 66 | $this->commandCallback = $commandCallback; |
| 64 | 67 | } |
| 65 | 68 | |
| 69 | + /** |
|
| 70 | + * @param CommandProcessor $commandProcessor |
|
| 71 | + */ |
|
| 66 | 72 | public function setCommandProcessor($commandProcessor) |
| 67 | 73 | { |
| 68 | 74 | $this->commandProcessor = $commandProcessor; |
@@ -102,6 +108,9 @@ discard block |
||
| 102 | 108 | $this->annotationData = $annotationData; |
| 103 | 109 | } |
| 104 | 110 | |
| 111 | + /** |
|
| 112 | + * @param CommandInfo $commandInfo |
|
| 113 | + */ |
|
| 105 | 114 | public function setCommandInfo($commandInfo) |
| 106 | 115 | { |
| 107 | 116 | $this->setDescription($commandInfo->getDescription()); |
@@ -178,6 +187,9 @@ discard block |
||
| 178 | 187 | return InputArgument::OPTIONAL; |
| 179 | 188 | } |
| 180 | 189 | |
| 190 | + /** |
|
| 191 | + * @param CommandInfo $commandInfo |
|
| 192 | + */ |
|
| 181 | 193 | public function setCommandOptions($commandInfo, $automaticOptions = []) |
| 182 | 194 | { |
| 183 | 195 | $inputOptions = $commandInfo->inputOptions(); |
@@ -241,6 +253,9 @@ discard block |
||
| 241 | 253 | return $args; |
| 242 | 254 | } |
| 243 | 255 | |
| 256 | + /** |
|
| 257 | + * @param InputInterface $input |
|
| 258 | + */ |
|
| 244 | 259 | protected function getArgsAndOptions($input) |
| 245 | 260 | { |
| 246 | 261 | if (!$input) { |
@@ -252,6 +267,9 @@ discard block |
||
| 252 | 267 | return $args; |
| 253 | 268 | } |
| 254 | 269 | |
| 270 | + /** |
|
| 271 | + * @param PassThroughArgsInput $input |
|
| 272 | + */ |
|
| 255 | 273 | protected function appendPassThroughArgs($input, $args) |
| 256 | 274 | { |
| 257 | 275 | $passThrough = $input->getPassThroughArgs(); |
@@ -3,8 +3,6 @@ |
||
| 3 | 3 | |
| 4 | 4 | use Consolidation\AnnotatedCommand\Hooks\HookManager; |
| 5 | 5 | use Consolidation\AnnotatedCommand\Parser\CommandInfo; |
| 6 | -use Consolidation\OutputFormatters\FormatterManager; |
|
| 7 | -use Consolidation\OutputFormatters\Options\FormatterOptions; |
|
| 8 | 6 | use Symfony\Component\Console\Command\Command; |
| 9 | 7 | use Symfony\Component\Console\Input\InputArgument; |
| 10 | 8 | use Symfony\Component\Console\Input\InputInterface; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | /** |
| 61 | 61 | * Add a hook |
| 62 | 62 | * |
| 63 | - * @param mixed $callback The callback function to call |
|
| 63 | + * @param callable $callback The callback function to call |
|
| 64 | 64 | * @param string $hook The name of the hook to add |
| 65 | 65 | * @param string $name The name of the command to hook |
| 66 | 66 | * ('*' for all) |
@@ -73,11 +73,17 @@ discard block |
||
| 73 | 73 | $this->hooks[$name][$hook][] = $callback; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | + /** |
|
| 77 | + * @param \Consolidation\AnnotatedCommand\Parser\CommandInfo $commandInfo |
|
| 78 | + */ |
|
| 76 | 79 | public function recordHookOptions($commandInfo, $name) |
| 77 | 80 | { |
| 78 | 81 | $this->hookOptions[$name][] = $commandInfo; |
| 79 | 82 | } |
| 80 | 83 | |
| 84 | + /** |
|
| 85 | + * @param \Consolidation\AnnotatedCommand\AnnotatedCommand $command |
|
| 86 | + */ |
|
| 81 | 87 | public static function getNames($command, $callback) |
| 82 | 88 | { |
| 83 | 89 | return array_filter( |
@@ -289,6 +295,9 @@ discard block |
||
| 289 | 295 | $command->optionsHookForHookAnnotations($commandInfoList); |
| 290 | 296 | } |
| 291 | 297 | |
| 298 | + /** |
|
| 299 | + * @param \Consolidation\AnnotatedCommand\AnnotatedCommand $command |
|
| 300 | + */ |
|
| 292 | 301 | protected function getHookOptionsForCommand($command) |
| 293 | 302 | { |
| 294 | 303 | if (isset($this->hookOptions[$command->getName()])) { |
@@ -389,6 +398,9 @@ discard block |
||
| 389 | 398 | return $result; |
| 390 | 399 | } |
| 391 | 400 | |
| 401 | + /** |
|
| 402 | + * @param string[] $names |
|
| 403 | + */ |
|
| 392 | 404 | protected function getCommandEventHooks($names) |
| 393 | 405 | { |
| 394 | 406 | return $this->getHooks($names, self::COMMAND_EVENT); |
@@ -449,6 +461,7 @@ discard block |
||
| 449 | 461 | * @param string|array $names The name of the function being hooked. |
| 450 | 462 | * @param string $hook The specific hook name (e.g. alter) |
| 451 | 463 | * @param string[] $stages The stages to apply hooks at (e.g. pre, post) |
| 464 | + * @param AnnotationData $annotationData |
|
| 452 | 465 | * |
| 453 | 466 | * @return callable[] |
| 454 | 467 | */ |
@@ -499,6 +512,10 @@ discard block |
||
| 499 | 512 | return []; |
| 500 | 513 | } |
| 501 | 514 | |
| 515 | + /** |
|
| 516 | + * @param callable $provider |
|
| 517 | + * @param InputInterface $input |
|
| 518 | + */ |
|
| 502 | 519 | protected function callInjectConfigurationHook($provider, $input, AnnotationData $annotationData) |
| 503 | 520 | { |
| 504 | 521 | if ($provider instanceof InitializeHookInterface) { |
@@ -509,6 +526,10 @@ discard block |
||
| 509 | 526 | } |
| 510 | 527 | } |
| 511 | 528 | |
| 529 | + /** |
|
| 530 | + * @param callable $optionHook |
|
| 531 | + * @param \Consolidation\AnnotatedCommand\AnnotatedCommand $command |
|
| 532 | + */ |
|
| 512 | 533 | protected function callOptionHook($optionHook, $command, AnnotationData $annotationData) |
| 513 | 534 | { |
| 514 | 535 | if ($optionHook instanceof OptionHookInterface) { |
@@ -519,6 +540,11 @@ discard block |
||
| 519 | 540 | } |
| 520 | 541 | } |
| 521 | 542 | |
| 543 | + /** |
|
| 544 | + * @param callable $interactor |
|
| 545 | + * @param InputInterface $input |
|
| 546 | + * @param OutputInterface $output |
|
| 547 | + */ |
|
| 522 | 548 | protected function callInteractor($interactor, $input, $output, AnnotationData $annotationData) |
| 523 | 549 | { |
| 524 | 550 | if ($interactor instanceof InteractorInterface) { |
@@ -529,6 +555,9 @@ discard block |
||
| 529 | 555 | } |
| 530 | 556 | } |
| 531 | 557 | |
| 558 | + /** |
|
| 559 | + * @param callable $validator |
|
| 560 | + */ |
|
| 532 | 561 | protected function callValidator($validator, $args, AnnotationData $annotationData) |
| 533 | 562 | { |
| 534 | 563 | // TODO: Adding AnnotationData to ValidatorInterface would be |
@@ -542,6 +571,9 @@ discard block |
||
| 542 | 571 | } |
| 543 | 572 | } |
| 544 | 573 | |
| 574 | + /** |
|
| 575 | + * @param callable $processor |
|
| 576 | + */ |
|
| 545 | 577 | protected function callProcessor($processor, $result, $args, AnnotationData $annotationData) |
| 546 | 578 | { |
| 547 | 579 | $processed = null; |
@@ -560,6 +592,9 @@ discard block |
||
| 560 | 592 | return $result; |
| 561 | 593 | } |
| 562 | 594 | |
| 595 | + /** |
|
| 596 | + * @param callable $determiner |
|
| 597 | + */ |
|
| 563 | 598 | protected function callDeterminer($determiner, $result) |
| 564 | 599 | { |
| 565 | 600 | if ($determiner instanceof StatusDeterminerInterface) { |
@@ -570,6 +605,9 @@ discard block |
||
| 570 | 605 | } |
| 571 | 606 | } |
| 572 | 607 | |
| 608 | + /** |
|
| 609 | + * @param callable $extractor |
|
| 610 | + */ |
|
| 573 | 611 | protected function callExtractor($extractor, $result) |
| 574 | 612 | { |
| 575 | 613 | if ($extractor instanceof ExtractOutputInterface) { |