diff --git a/src/Task/AbstractExternalTask.php b/src/Task/AbstractExternalTask.php index 5aa8c8fb..c5a49a06 100644 --- a/src/Task/AbstractExternalTask.php +++ b/src/Task/AbstractExternalTask.php @@ -14,6 +14,8 @@ */ abstract class AbstractExternalTask implements TaskInterface { + use GitContextTrait; + /** * @var TaskConfigInterface */ diff --git a/src/Task/AbstractLinterTask.php b/src/Task/AbstractLinterTask.php index 4a3b3194..92208a45 100644 --- a/src/Task/AbstractLinterTask.php +++ b/src/Task/AbstractLinterTask.php @@ -17,6 +17,8 @@ */ abstract class AbstractLinterTask implements TaskInterface { + use GitContextTrait; + /** * @var TaskConfigInterface */ diff --git a/src/Task/AbstractParserTask.php b/src/Task/AbstractParserTask.php index c40c4b90..04203898 100644 --- a/src/Task/AbstractParserTask.php +++ b/src/Task/AbstractParserTask.php @@ -17,6 +17,8 @@ */ abstract class AbstractParserTask implements TaskInterface { + use GitContextTrait; + /** * @var TaskConfigInterface */ diff --git a/src/Task/Ant.php b/src/Task/Ant.php index f6d50653..55cc0a7a 100644 --- a/src/Task/Ant.php +++ b/src/Task/Ant.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -36,7 +35,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Atoum.php b/src/Task/Atoum.php index 4ae47dd4..97551722 100644 --- a/src/Task/Atoum.php +++ b/src/Task/Atoum.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -47,7 +46,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Behat.php b/src/Task/Behat.php index 50988de8..a7efeef5 100644 --- a/src/Task/Behat.php +++ b/src/Task/Behat.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -43,7 +42,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Brunch.php b/src/Task/Brunch.php index d60f6614..fbd27cc8 100644 --- a/src/Task/Brunch.php +++ b/src/Task/Brunch.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -43,7 +42,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/CloverCoverage.php b/src/Task/CloverCoverage.php index 9315a360..85053cef 100644 --- a/src/Task/CloverCoverage.php +++ b/src/Task/CloverCoverage.php @@ -10,7 +10,6 @@ use GrumPHP\Task\Config\EmptyTaskConfig; use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use GrumPHP\Util\Filesystem; use SimpleXMLElement; @@ -19,6 +18,8 @@ class CloverCoverage implements TaskInterface { + use GitContextTrait; + /** * @var Filesystem */ @@ -72,7 +73,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Codeception.php b/src/Task/Codeception.php index 2a228959..b78df822 100644 --- a/src/Task/Codeception.php +++ b/src/Task/Codeception.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -45,7 +44,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Composer.php b/src/Task/Composer.php index 9290e0ce..e36e4634 100644 --- a/src/Task/Composer.php +++ b/src/Task/Composer.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use GrumPHP\Util\Filesystem; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -61,7 +60,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/ComposerNormalize.php b/src/Task/ComposerNormalize.php index e2af7161..468c6784 100644 --- a/src/Task/ComposerNormalize.php +++ b/src/Task/ComposerNormalize.php @@ -8,7 +8,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Process\Process; @@ -20,7 +19,7 @@ class ComposerNormalize extends AbstractExternalTask { public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public static function getConfigurableOptions(): ConfigOptionsResolver diff --git a/src/Task/ComposerRequireChecker.php b/src/Task/ComposerRequireChecker.php index 46ed1ce6..febbdca5 100644 --- a/src/Task/ComposerRequireChecker.php +++ b/src/Task/ComposerRequireChecker.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -41,7 +40,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/ComposerScript.php b/src/Task/ComposerScript.php index 1def9a99..a1cc6595 100644 --- a/src/Task/ComposerScript.php +++ b/src/Task/ComposerScript.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Deptrac.php b/src/Task/Deptrac.php index 3c407833..39482611 100644 --- a/src/Task/Deptrac.php +++ b/src/Task/Deptrac.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -38,7 +37,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/DoctrineOrm.php b/src/Task/DoctrineOrm.php index 356e85a3..1325d2f2 100644 --- a/src/Task/DoctrineOrm.php +++ b/src/Task/DoctrineOrm.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/ESLint.php b/src/Task/ESLint.php index 51816c3d..283c89dc 100644 --- a/src/Task/ESLint.php +++ b/src/Task/ESLint.php @@ -11,7 +11,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -60,7 +59,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return ($context instanceof GitPreCommitContext || $context instanceof RunContext); + return ($this->isGitContextAllowed($context) || $context instanceof RunContext); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Ecs.php b/src/Task/Ecs.php index 93d70353..0fc8d059 100644 --- a/src/Task/Ecs.php +++ b/src/Task/Ecs.php @@ -12,7 +12,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Process\Process; @@ -48,7 +47,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface @@ -102,7 +101,7 @@ private function addPaths( FilesCollection $files, array $config ): void { - if ($context instanceof GitPreCommitContext && $config['files_on_pre_commit']) { + if ($this->isGitContextAllowed($context) && $config['files_on_pre_commit']) { $arguments->addFiles($files); return; } diff --git a/src/Task/FileSize.php b/src/Task/FileSize.php index fd85a313..305aff6d 100644 --- a/src/Task/FileSize.php +++ b/src/Task/FileSize.php @@ -10,12 +10,13 @@ use GrumPHP\Task\Config\EmptyTaskConfig; use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; class FileSize implements TaskInterface { + use GitContextTrait; + /** * @var TaskConfigInterface */ @@ -55,7 +56,7 @@ public function withConfig(TaskConfigInterface $config): TaskInterface public function canRunInContext(ContextInterface $context): bool { - return $context instanceof RunContext || $context instanceof GitPreCommitContext; + return $context instanceof RunContext || $this->isGitContextAllowed($context); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Gherkin.php b/src/Task/Gherkin.php index 00fc4cd1..824ca6ed 100644 --- a/src/Task/Gherkin.php +++ b/src/Task/Gherkin.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -38,7 +37,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Git/Blacklist.php b/src/Task/Git/Blacklist.php index f30793f8..a43b2433 100644 --- a/src/Task/Git/Blacklist.php +++ b/src/Task/Git/Blacklist.php @@ -12,7 +12,6 @@ use GrumPHP\Task\AbstractExternalTask; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use Symfony\Component\OptionsResolver\OptionsResolver; /** @@ -63,7 +62,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext; + return $this->isGitContextAllowed($context); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Git/BranchName.php b/src/Task/Git/BranchName.php index 0084f1c1..816eb553 100644 --- a/src/Task/Git/BranchName.php +++ b/src/Task/Git/BranchName.php @@ -12,14 +12,16 @@ use GrumPHP\Task\Config\EmptyTaskConfig; use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; +use GrumPHP\Task\GitContextTrait; use GrumPHP\Util\Regex; use GrumPHP\Task\TaskInterface; use Symfony\Component\OptionsResolver\OptionsResolver; class BranchName implements TaskInterface { + use GitContextTrait; + /** * @var TaskConfigInterface */ @@ -69,7 +71,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof RunContext || $context instanceof GitPreCommitContext; + return $context instanceof RunContext || $this->isGitContextAllowed($context); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Grunt.php b/src/Task/Grunt.php index c284887b..c89ccd17 100644 --- a/src/Task/Grunt.php +++ b/src/Task/Grunt.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Gulp.php b/src/Task/Gulp.php index 215384e1..a2442ae3 100644 --- a/src/Task/Gulp.php +++ b/src/Task/Gulp.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Infection.php b/src/Task/Infection.php index 65d83152..0a0b311c 100644 --- a/src/Task/Infection.php +++ b/src/Task/Infection.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -56,7 +55,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** @@ -86,7 +85,7 @@ public function run(ContextInterface $context): TaskResultInterface $arguments->addOptionalArgument('--min-covered-msi=%s', $config['min_covered_msi']); $arguments->addOptionalCommaSeparatedArgument('--mutators=%s', $config['mutators']); - if ($context instanceof GitPreCommitContext) { + if ($this->isGitContextAllowed($context)) { $arguments->addArgumentWithCommaSeparatedFiles('--filter=%s', $files); } diff --git a/src/Task/JsonLint.php b/src/Task/JsonLint.php index d928df9e..4792d686 100644 --- a/src/Task/JsonLint.php +++ b/src/Task/JsonLint.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -41,7 +40,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Kahlan.php b/src/Task/Kahlan.php index c4262adf..6120e779 100644 --- a/src/Task/Kahlan.php +++ b/src/Task/Kahlan.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -72,7 +71,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Make.php b/src/Task/Make.php index d8750f07..b46fd177 100644 --- a/src/Task/Make.php +++ b/src/Task/Make.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/NpmScript.php b/src/Task/NpmScript.php index 88e7a536..c77d315b 100644 --- a/src/Task/NpmScript.php +++ b/src/Task/NpmScript.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -43,7 +42,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $t || $context instanceof RunContext; } /** diff --git a/src/Task/Paratest.php b/src/Task/Paratest.php index 602809cb..768174ce 100644 --- a/src/Task/Paratest.php +++ b/src/Task/Paratest.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -60,7 +59,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Pest.php b/src/Task/Pest.php index e1c33a29..23744f54 100644 --- a/src/Task/Pest.php +++ b/src/Task/Pest.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -38,7 +37,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Phan.php b/src/Task/Phan.php index a42a8e4e..138ef4ea 100644 --- a/src/Task/Phan.php +++ b/src/Task/Phan.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -43,7 +42,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Phing.php b/src/Task/Phing.php index 7ccb2358..0cda73be 100644 --- a/src/Task/Phing.php +++ b/src/Task/Phing.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Php7cc.php b/src/Task/Php7cc.php index 21186a4a..c156c006 100644 --- a/src/Task/Php7cc.php +++ b/src/Task/Php7cc.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof RunContext || $context instanceof GitPreCommitContext; + return $context instanceof RunContext || $this->isGitContextAllowed($context); } /** diff --git a/src/Task/PhpArkitect.php b/src/Task/PhpArkitect.php index 5a35785c..bd9addfc 100644 --- a/src/Task/PhpArkitect.php +++ b/src/Task/PhpArkitect.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/PhpCpd.php b/src/Task/PhpCpd.php index 87476dc5..a0a1bcdb 100644 --- a/src/Task/PhpCpd.php +++ b/src/Task/PhpCpd.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -45,7 +44,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/PhpCsFixer.php b/src/Task/PhpCsFixer.php index cfec6ae9..93555c9c 100644 --- a/src/Task/PhpCsFixer.php +++ b/src/Task/PhpCsFixer.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Process\Process; @@ -58,7 +57,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** @@ -97,7 +96,7 @@ public function run(ContextInterface $context): TaskResultInterface $arguments->addOptionalArgument('--diff', $config['diff']); $arguments->add('fix'); - if ($context instanceof GitPreCommitContext || !$config['config_contains_finder']) { + if ($this->isGitContextAllowed($context) || !$config['config_contains_finder']) { $arguments->addFiles($files); } diff --git a/src/Task/PhpLint.php b/src/Task/PhpLint.php index 108c1953..21e98d24 100644 --- a/src/Task/PhpLint.php +++ b/src/Task/PhpLint.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Process\Process; @@ -42,7 +41,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof RunContext || $context instanceof GitPreCommitContext; + return $context instanceof RunContext || $this->isGitContextAllowed($context); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/PhpMd.php b/src/Task/PhpMd.php index 1aeccdaa..88edd9ba 100644 --- a/src/Task/PhpMd.php +++ b/src/Task/PhpMd.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -44,7 +43,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/PhpMnd.php b/src/Task/PhpMnd.php index 00caa55a..28e8606c 100644 --- a/src/Task/PhpMnd.php +++ b/src/Task/PhpMnd.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -57,7 +56,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/PhpParser.php b/src/Task/PhpParser.php index 7fef195c..b1ae4cf5 100644 --- a/src/Task/PhpParser.php +++ b/src/Task/PhpParser.php @@ -6,7 +6,6 @@ use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use GrumPHP\Runner\TaskResult; use GrumPHP\Runner\TaskResultInterface; @@ -44,7 +43,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/PhpStan.php b/src/Task/PhpStan.php index 0fa048bd..c7c3de43 100644 --- a/src/Task/PhpStan.php +++ b/src/Task/PhpStan.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -60,7 +59,7 @@ function ($value) { */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/PhpVersion.php b/src/Task/PhpVersion.php index 26393535..58c6a935 100644 --- a/src/Task/PhpVersion.php +++ b/src/Task/PhpVersion.php @@ -11,13 +11,14 @@ use GrumPHP\Task\Config\EmptyTaskConfig; use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use GrumPHP\Util\PhpVersion as PhpVersionUtility; use Symfony\Component\OptionsResolver\OptionsResolver; class PhpVersion implements TaskInterface { + use GitContextTrait; + /** * @var TaskConfigInterface */ @@ -36,7 +37,7 @@ public function __construct(PhpVersionUtility $phpVersionUtility) public function canRunInContext(ContextInterface $context): bool { - return $context instanceof RunContext || $context instanceof GitPreCommitContext; + return $context instanceof RunContext || $this->isGitContextAllowed($context); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Phpcs.php b/src/Task/Phpcs.php index c16320b3..14bd395c 100644 --- a/src/Task/Phpcs.php +++ b/src/Task/Phpcs.php @@ -14,7 +14,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\Console\Exception\CommandNotFoundException; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -70,7 +69,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Phpspec.php b/src/Task/Phpspec.php index c5ae9988..f85f1e11 100644 --- a/src/Task/Phpspec.php +++ b/src/Task/Phpspec.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -38,7 +37,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Phpunit.php b/src/Task/Phpunit.php index 857950bd..f86a893f 100644 --- a/src/Task/Phpunit.php +++ b/src/Task/Phpunit.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -42,7 +41,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/PhpunitBridge.php b/src/Task/PhpunitBridge.php index 5c1472f8..51d07fb6 100644 --- a/src/Task/PhpunitBridge.php +++ b/src/Task/PhpunitBridge.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -42,7 +41,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return ($context instanceof GitPreCommitContext || $context instanceof RunContext); + return ($this->isGitContextAllowed($context) || $context instanceof RunContext); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Progpilot.php b/src/Task/Progpilot.php index d5162c9c..b6179ec5 100644 --- a/src/Task/Progpilot.php +++ b/src/Task/Progpilot.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -34,7 +33,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return ($context instanceof GitPreCommitContext || $context instanceof RunContext); + return ($this->isGitContextAllowed($context) || $context instanceof RunContext); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Psalm.php b/src/Task/Psalm.php index b4415a21..9941ddfa 100644 --- a/src/Task/Psalm.php +++ b/src/Task/Psalm.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -54,7 +53,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return ($context instanceof GitPreCommitContext || $context instanceof RunContext); + return ($this->isGitContextAllowed($context) || $context instanceof RunContext); } public function run(ContextInterface $context): TaskResultInterface @@ -78,7 +77,7 @@ public function run(ContextInterface $context): TaskResultInterface $arguments->addOptionalArgument('--threads=%d', $config['threads']); $arguments->addOptionalBooleanArgument('--show-info=%s', $config['show_info'], 'true', 'false'); - if ($context instanceof GitPreCommitContext) { + if ($this->isGitContextAllowed($context)) { $arguments->addFiles($files); } diff --git a/src/Task/Rector.php b/src/Task/Rector.php index ac23c9e7..7f2a346e 100644 --- a/src/Task/Rector.php +++ b/src/Task/Rector.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Process\Process; @@ -42,7 +41,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof RunContext || $context instanceof GitPreCommitContext; + return $context instanceof RunContext || $this->isGitContextAllowed($context); } public function run(ContextInterface $context): TaskResultInterface @@ -68,7 +67,7 @@ public function run(ContextInterface $context): TaskResultInterface $arguments->addOptionalArgument('--clear-cache', $config['clear_cache']); $arguments->addOptionalArgument('--no-diffs', $config['no_diffs']); - if ($context instanceof GitPreCommitContext) { + if ($this->isGitContextAllowed($context)) { $arguments->addFiles($files); } diff --git a/src/Task/Robo.php b/src/Task/Robo.php index d33e4314..2a1686c4 100644 --- a/src/Task/Robo.php +++ b/src/Task/Robo.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -39,7 +38,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/SecurityChecker.php b/src/Task/SecurityChecker.php index 4937f74b..cbd4fa0e 100644 --- a/src/Task/SecurityChecker.php +++ b/src/Task/SecurityChecker.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -40,7 +39,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/SecurityCheckerComposeraudit.php b/src/Task/SecurityCheckerComposeraudit.php index d57dc1a6..798b38ce 100644 --- a/src/Task/SecurityCheckerComposeraudit.php +++ b/src/Task/SecurityCheckerComposeraudit.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -40,7 +39,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/SecurityCheckerEnlightn.php b/src/Task/SecurityCheckerEnlightn.php index 614e41ec..4cb562fe 100644 --- a/src/Task/SecurityCheckerEnlightn.php +++ b/src/Task/SecurityCheckerEnlightn.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -34,7 +33,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/SecurityCheckerLocal.php b/src/Task/SecurityCheckerLocal.php index 5858a400..672f9e19 100644 --- a/src/Task/SecurityCheckerLocal.php +++ b/src/Task/SecurityCheckerLocal.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -38,7 +37,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/SecurityCheckerRoave.php b/src/Task/SecurityCheckerRoave.php index 548d6cde..620b180c 100644 --- a/src/Task/SecurityCheckerRoave.php +++ b/src/Task/SecurityCheckerRoave.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use GrumPHP\Util\Filesystem; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -50,7 +49,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/SecurityCheckerSymfony.php b/src/Task/SecurityCheckerSymfony.php index bbb77ba5..20d3c03c 100644 --- a/src/Task/SecurityCheckerSymfony.php +++ b/src/Task/SecurityCheckerSymfony.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -36,7 +35,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Shell.php b/src/Task/Shell.php index ab4b1f6c..f5fd26b1 100644 --- a/src/Task/Shell.php +++ b/src/Task/Shell.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -50,7 +49,7 @@ function ($script) { */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/Stylelint.php b/src/Task/Stylelint.php index dd3053d8..e232afd1 100644 --- a/src/Task/Stylelint.php +++ b/src/Task/Stylelint.php @@ -11,7 +11,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Process\Process; @@ -83,7 +82,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return ($context instanceof GitPreCommitContext || $context instanceof RunContext); + return ($this->isGitContextAllowed($context) || $context instanceof RunContext); } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/Tester.php b/src/Task/Tester.php index 0f94b281..ac29947c 100644 --- a/src/Task/Tester.php +++ b/src/Task/Tester.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -58,7 +57,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface diff --git a/src/Task/TwigCs.php b/src/Task/TwigCs.php index 125f9669..4e008269 100644 --- a/src/Task/TwigCs.php +++ b/src/Task/TwigCs.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -42,7 +41,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface @@ -71,7 +70,7 @@ public function run(ContextInterface $context): TaskResultInterface ); $arguments->addArgumentArray('--exclude=%s', $exclude); - if ($context instanceof GitPreCommitContext) { + if ($this->isGitContextAllowed($context)) { $arguments->addFiles($files); } diff --git a/src/Task/TwigCsFixer.php b/src/Task/TwigCsFixer.php index 20bdaa8b..26b0eac1 100644 --- a/src/Task/TwigCsFixer.php +++ b/src/Task/TwigCsFixer.php @@ -9,7 +9,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; use GrumPHP\Fixer\Provider\FixableProcessResultProvider; @@ -45,7 +44,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface @@ -62,7 +61,7 @@ public function run(ContextInterface $context): TaskResultInterface $arguments = $this->processBuilder->createArgumentsForCommand('twig-cs-fixer'); $arguments->add('lint'); - if ($context instanceof GitPreCommitContext) { + if ($this->isGitContextAllowed($context)) { $arguments->addFiles($files); } diff --git a/src/Task/XmlLint.php b/src/Task/XmlLint.php index d8c2ebd2..154e7be0 100644 --- a/src/Task/XmlLint.php +++ b/src/Task/XmlLint.php @@ -10,7 +10,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -49,7 +48,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver */ public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } /** diff --git a/src/Task/YamlLint.php b/src/Task/YamlLint.php index d0064582..55a196a6 100644 --- a/src/Task/YamlLint.php +++ b/src/Task/YamlLint.php @@ -11,7 +11,6 @@ use GrumPHP\Runner\TaskResultInterface; use GrumPHP\Task\Config\ConfigOptionsResolver; use GrumPHP\Task\Context\ContextInterface; -use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -48,7 +47,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver public function canRunInContext(ContextInterface $context): bool { - return $context instanceof GitPreCommitContext || $context instanceof RunContext; + return $this->isGitContextAllowed($context) || $context instanceof RunContext; } public function run(ContextInterface $context): TaskResultInterface