Skip to content

Commit

Permalink
Use the new trait
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiu-cristea committed May 26, 2024
1 parent c7cc1b5 commit 0cb1122
Show file tree
Hide file tree
Showing 63 changed files with 82 additions and 127 deletions.
2 changes: 2 additions & 0 deletions src/Task/AbstractExternalTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
abstract class AbstractExternalTask implements TaskInterface
{
use GitContextTrait;

/**
* @var TaskConfigInterface
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Task/AbstractLinterTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
abstract class AbstractLinterTask implements TaskInterface
{
use GitContextTrait;

/**
* @var TaskConfigInterface
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Task/AbstractParserTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
abstract class AbstractParserTask implements TaskInterface
{
use GitContextTrait;

/**
* @var TaskConfigInterface
*/
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Ant.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Atoum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Behat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Brunch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/Task/CloverCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,6 +18,8 @@

class CloverCoverage implements TaskInterface
{
use GitContextTrait;

/**
* @var Filesystem
*/
Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Codeception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Task/ComposerNormalize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Task/ComposerRequireChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/ComposerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Deptrac.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Task/DoctrineOrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/ESLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/Task/Ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Task/FileSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Gherkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Git/Blacklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/Task/Git/BranchName.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Task/Grunt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
Loading

0 comments on commit 0cb1122

Please sign in to comment.