diff --git a/spec/Task/ProgpilotSpec.php b/spec/Task/ProgpilotSpec.php index 8ad842a29..8165d1760 100644 --- a/spec/Task/ProgpilotSpec.php +++ b/spec/Task/ProgpilotSpec.php @@ -86,8 +86,11 @@ function it_runs_the_suite(ProcessBuilder $processBuilder, Process $process, Con function it_throws_exception_if_the_process_fails( ProcessBuilder $processBuilder, Process $process, - ContextInterface $context + ContextInterface $context, + ProcessFormatterInterface $formatter ) { + $formatter->format($process)->willReturn('format string'); + $arguments = new ProcessArgumentsCollection(); $processBuilder->createArgumentsForCommand('progpilot')->willReturn($arguments); $processBuilder->buildProcess($arguments)->willReturn($process); diff --git a/src/Task/Progpilot.php b/src/Task/Progpilot.php index 74bdba394..b4e3eb39f 100644 --- a/src/Task/Progpilot.php +++ b/src/Task/Progpilot.php @@ -3,36 +3,26 @@ namespace GrumPHP\Task; use GrumPHP\Runner\TaskResult; +use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Context\ContextInterface; use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; -/** - * Progpilot task - */ class Progpilot extends AbstractExternalTask { - /** - * @return string - */ - public function getName() + public function getName(): string { return 'progpilot'; } - /** - * @return OptionsResolver - */ - public function getConfigurableOptions() + public function getConfigurableOptions(): OptionsResolver { $resolver = new OptionsResolver(); - $resolver->setDefaults( - [ + $resolver->setDefaults([ 'config_file' => '.progpilot/configuration.yml', 'triggered_by' => ['php'] - ] - ); + ]); $resolver->addAllowedTypes('config_file', ['string', 'null']); $resolver->addAllowedTypes('triggered_by', ['array']); @@ -40,18 +30,12 @@ public function getConfigurableOptions() return $resolver; } - /** - * {@inheritdoc} - */ - public function canRunInContext(ContextInterface $context) + public function canRunInContext(ContextInterface $context): bool { return ($context instanceof GitPreCommitContext || $context instanceof RunContext); } - /** - * {@inheritdoc} - */ - public function run(ContextInterface $context) + public function run(ContextInterface $context): TaskResultInterface { $config = $this->getConfiguration(); $files = $context->getFiles()->extensions($config['triggered_by']);