From eb341bb91c11961b8d7f4c170e96934d4dc2f14b Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:19:38 +0200 Subject: [PATCH 01/13] Grumphp update from 0.16 to 1.0 version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d128133..94ddca4 100755 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "bin": ["bin/check_perms"], "require": { "symfony/polyfill-iconv": "^1", - "phpro/grumphp": "^0.16.0", + "phpro/grumphp": "^1", "drupal/coder": "^8", "phpcompatibility/php-compatibility": "^9.3", "pheromone/phpcs-security-audit": "^2.0", From d76696056f53cf1cbcb713cf73ba5a08a5520ac0 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:28:14 +0200 Subject: [PATCH 02/13] Make load() non-returnable. Change service configuration + tag (config -> task) --- src/Task/AbstractExternalExtensionLoader.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Task/AbstractExternalExtensionLoader.php b/src/Task/AbstractExternalExtensionLoader.php index c469a34..891fd49 100644 --- a/src/Task/AbstractExternalExtensionLoader.php +++ b/src/Task/AbstractExternalExtensionLoader.php @@ -6,7 +6,6 @@ use GrumPHP\Extension\ExtensionInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Yaml\Yaml; @@ -57,17 +56,14 @@ public function __construct() { /** * {@inheritdoc} */ - public function load(ContainerBuilder $container): Definition { + public function load(ContainerBuilder $container): void { $task = $container->register('task.' . $this->name, $this->class); - $task->addTag('grumphp.task', ['config' => $this->name]); - if (empty($this->arguments)) { - return $task; + if (!empty($this->arguments)) { + foreach ($this->arguments as $argument) { + $task->addArgument(new Reference($argument)); + } } - foreach ($this->arguments as $argument) { - $task->addArgument(new Reference($argument)); - } - - return $task; + $task->addTag('grumphp.task', ['task' => $this->name]); } } From 311366cf1525d35c39e0bb1d8420d7b4a4339442 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:34:34 +0200 Subject: [PATCH 03/13] Updated construction. Added getConfig() and immutable withConfig() methods. --- src/Task/AbstractProcessingTask.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Task/AbstractProcessingTask.php b/src/Task/AbstractProcessingTask.php index 7460726..2948661 100644 --- a/src/Task/AbstractProcessingTask.php +++ b/src/Task/AbstractProcessingTask.php @@ -4,12 +4,13 @@ namespace Wunderio\GrumPHP\Task; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; use GrumPHP\Runner\TaskResult; use GrumPHP\Task\AbstractExternalTask; +use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; +use GrumPHP\Task\TaskInterface; use Symfony\Component\Process\Process; /** @@ -25,15 +26,11 @@ abstract class AbstractProcessingTask extends AbstractExternalTask implements Co /** * AbstractProcessingTask constructor. * - * @param \GrumPHP\Configuration\GrumPHP $grum_php - * Grumphp. - * @param \GrumPHP\Process\ProcessBuilder $process_builder - * ProcessBuilder. + * @param \GrumPHP\Process\ProcessBuilder $processBuilder * @param \GrumPHP\Formatter\ProcessFormatterInterface $formatter - * Formatter. */ - public function __construct(GrumPHP $grum_php, ProcessBuilder $process_builder, ProcessFormatterInterface $formatter) { - parent::__construct($grum_php, $process_builder, $formatter); + public function __construct(ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter) { + parent::__construct($processBuilder, $formatter); $this->configure(); } @@ -49,6 +46,8 @@ public function __construct(GrumPHP $grum_php, ProcessBuilder $process_builder, * Result. */ public function getTaskResult(Process $process, ContextInterface $context): TaskResult { + $this->configure(); + if (!$process->isSuccessful()) { return TaskResult::createFailed($this, $context, $this->formatter->format($process)); } @@ -56,4 +55,16 @@ public function getTaskResult(Process $process, ContextInterface $context): Task return TaskResult::createPassed($this, $context); } + public function getConfig(): TaskConfigInterface + { + return $this->config; + } + + public function withConfig(TaskConfigInterface $config): TaskInterface + { + $new = clone $this; + $new->config = $config; + + return $new; + } } From a170c5cc93c127b8ad1ab62d92ecda95efdd3f00 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:35:32 +0200 Subject: [PATCH 04/13] Replaced getConfiguration() method by the getConfig() method --- src/Task/AbstractMultiPathProcessingTask.php | 2 +- src/Task/AbstractSinglePathProcessingTask.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Task/AbstractMultiPathProcessingTask.php b/src/Task/AbstractMultiPathProcessingTask.php index fdf3dab..ae4a5c0 100644 --- a/src/Task/AbstractMultiPathProcessingTask.php +++ b/src/Task/AbstractMultiPathProcessingTask.php @@ -18,7 +18,7 @@ abstract class AbstractMultiPathProcessingTask extends AbstractProcessingTask im * {@inheritdoc} */ public function run(ContextInterface $context): TaskResultInterface { - $paths = $this->getPathsOrResult($context, $this->getConfiguration(), $this); + $paths = $this->getPathsOrResult($context, $this->getConfig()->getOptions(), $this); if ($paths instanceof TaskResultInterface) { return $paths; } diff --git a/src/Task/AbstractSinglePathProcessingTask.php b/src/Task/AbstractSinglePathProcessingTask.php index ff96bc9..9111fd8 100644 --- a/src/Task/AbstractSinglePathProcessingTask.php +++ b/src/Task/AbstractSinglePathProcessingTask.php @@ -20,7 +20,7 @@ abstract class AbstractSinglePathProcessingTask extends AbstractProcessingTask i * {@inheritdoc} */ public function run(ContextInterface $context): TaskResultInterface { - $paths = $this->getPathsOrResult($context, $this->getConfiguration(), $this); + $paths = $this->getPathsOrResult($context, $this->getConfig()->getOptions(), $this); if ($paths instanceof TaskResultInterface) { return $paths; } @@ -30,7 +30,7 @@ public function run(ContextInterface $context): TaskResultInterface { } $output = ''; // Split files in to executable chunks. - $path_chunks = array_chunk($paths, $this->getConfiguration()['parallelism'] ?? 100); + $path_chunks = array_chunk($paths, $this->getConfig()->getOptions()['parallelism'] ?? 100); foreach ($path_chunks as $path_list) { $output .= $this->runInParallel($path_list); } From 5bf39c70dce760fec919264c4896a934c152854c Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:38:03 +0200 Subject: [PATCH 05/13] Make getConfigurableOptions() static. Added getConfig() and immutable withConfig() methods. --- src/Task/ConfigurableTaskTrait.php | 31 ++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Task/ConfigurableTaskTrait.php b/src/Task/ConfigurableTaskTrait.php index 4bd3a3a..30b8ca5 100644 --- a/src/Task/ConfigurableTaskTrait.php +++ b/src/Task/ConfigurableTaskTrait.php @@ -4,8 +4,10 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Runner\TaskResult; +use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; use GrumPHP\Task\Context\GitPreCommitContext; +use GrumPHP\Task\TaskInterface; use Symfony\Component\Finder\Finder; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Yaml\Yaml; @@ -41,7 +43,7 @@ trait ConfigurableTaskTrait { /** * Configurable options. * - * @var array[] + * @var TaskConfigInterface */ public $configuration; @@ -67,23 +69,44 @@ public function getName(): string { return $this->name; } + public function getConfig(): TaskConfigInterface + { + return $this->config; + } + /** * {@inheritdoc} */ - public function getConfigurableOptions(): OptionsResolver { + public static function getConfigurableOptions(): OptionsResolver { + // Get configurable options. + $tasks = Yaml::parseFile(__DIR__ . '/tasks.yml'); + $default_configuration = $tasks['default']; + unset($default_configuration['name']); + $configurations = $tasks[static::class] ?? $default_configuration; + $configurable_options = $configurations['options'] ?? $default_configuration['options']; + + // Task config options. $resolver = new OptionsResolver(); $defaults = []; - foreach ($this->configurableOptions as $option_name => $option) { + foreach ($configurable_options as $option_name => $option) { $defaults[$option_name] = $option['defaults']; } $resolver->setDefaults($defaults); - foreach ($this->configurableOptions as $option_name => $option) { + foreach ($configurable_options as $option_name => $option) { $resolver->addAllowedTypes($option_name, $option['allowed_types']); } return $resolver; } + public function withConfig(TaskConfigInterface $config): TaskInterface + { + $new = clone $this; + $new->config = $config; + + return $new; + } + /** * Return appropriate files or directories based on context and configuration. * From e1eee78fbc6882d80a8dc697c827fd2145d5fe1e Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:39:11 +0200 Subject: [PATCH 06/13] Updated construction. Replaced getConfiguration() method by the getConfig() method --- src/Task/AbstractLintTask.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Task/AbstractLintTask.php b/src/Task/AbstractLintTask.php index 88ce88d..77b2265 100644 --- a/src/Task/AbstractLintTask.php +++ b/src/Task/AbstractLintTask.php @@ -5,7 +5,6 @@ namespace Wunderio\GrumPHP\Task; use GrumPHP\Collection\FilesCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Exception\RuntimeException; use GrumPHP\Linter\LinterInterface; use GrumPHP\Runner\TaskResult; @@ -26,13 +25,10 @@ abstract class AbstractLintTask extends AbstractLinterTask implements LintTaskIn /** * AbstractLintTask constructor. * - * @param \GrumPHP\Configuration\GrumPHP $grum_php - * GrumpPHP. * @param \GrumPHP\Linter\LinterInterface $linter - * Linter. */ - public function __construct(GrumPHP $grum_php, LinterInterface $linter) { - parent::__construct($grum_php, $linter); + public function __construct(LinterInterface $linter) { + parent::__construct($linter); $this->configure(); } @@ -40,7 +36,7 @@ public function __construct(GrumPHP $grum_php, LinterInterface $linter) { * {@inheritdoc} */ public function run(ContextInterface $context): TaskResultInterface { - $paths = $this->getPathsOrResult($context, $this->getConfiguration(), $this); + $paths = $this->getPathsOrResult($context, $this->getConfig()->getOptions(), $this); if ($paths instanceof TaskResultInterface) { return $paths; } From cbfb8725869ff6fa6956e3dc962ed731e0af0baa Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:41:35 +0200 Subject: [PATCH 07/13] Updated tasks. Replaced getConfiguration() method by the getConfig() method --- src/Task/Ecs/EcsTask.php | 2 +- src/Task/JsonLint/JsonLintTask.php | 2 +- src/Task/PhpCompatibility/PhpCompatibilityTask.php | 2 +- src/Task/Phpcs/PhpcsTask.php | 2 +- .../PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php | 2 +- src/Task/YamlLint/YamlLintTask.php | 2 +- src/Task/tasks.yml | 4 ---- 7 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Task/Ecs/EcsTask.php b/src/Task/Ecs/EcsTask.php index dd0ef45..63541f2 100644 --- a/src/Task/Ecs/EcsTask.php +++ b/src/Task/Ecs/EcsTask.php @@ -25,7 +25,7 @@ public function buildArguments(iterable $files): ProcessArgumentsCollection { $arguments->add($file); } - $config = $this->getConfiguration(); + $config = $this->getConfig()->getOptions(); $arguments->addOptionalArgument('--config=%s', $config['config']); $arguments->addOptionalArgument('--level=%s', $config['level']); $arguments->addOptionalArgument('--clear-cache', $config['clear-cache']); diff --git a/src/Task/JsonLint/JsonLintTask.php b/src/Task/JsonLint/JsonLintTask.php index 0084385..2166e1b 100644 --- a/src/Task/JsonLint/JsonLintTask.php +++ b/src/Task/JsonLint/JsonLintTask.php @@ -18,7 +18,7 @@ class JsonLintTask extends AbstractLintTask { * {@inheritdoc} */ public function configureLint(LinterInterface $linter): void { - $config = $this->getConfiguration(); + $config = $this->getConfig()->getOptions(); $linter->setDetectKeyConflicts($config['detect_key_conflicts']); } diff --git a/src/Task/PhpCompatibility/PhpCompatibilityTask.php b/src/Task/PhpCompatibility/PhpCompatibilityTask.php index bdc6f6f..4ce0310 100644 --- a/src/Task/PhpCompatibility/PhpCompatibilityTask.php +++ b/src/Task/PhpCompatibility/PhpCompatibilityTask.php @@ -19,7 +19,7 @@ class PhpCompatibilityTask extends AbstractMultiPathProcessingTask { */ public function buildArguments(iterable $files): ProcessArgumentsCollection { $arguments = $this->processBuilder->createArgumentsForCommand('phpcs'); - $config = $this->getConfiguration(); + $config = $this->getConfig()->getOptions(); $config['basepath'] = $config['basepath'] ?? '.'; $arguments->addOptionalCommaSeparatedArgument('--extensions=%s', (array) $config[self::D_EXT]); $arguments->addOptionalIntegerArgument('--parallel=%s', $config['parallel']); diff --git a/src/Task/Phpcs/PhpcsTask.php b/src/Task/Phpcs/PhpcsTask.php index d5cfd5a..98b3c5f 100644 --- a/src/Task/Phpcs/PhpcsTask.php +++ b/src/Task/Phpcs/PhpcsTask.php @@ -19,7 +19,7 @@ class PhpcsTask extends AbstractMultiPathProcessingTask { */ public function buildArguments(iterable $files): ProcessArgumentsCollection { $arguments = $this->processBuilder->createArgumentsForCommand('phpcs'); - $config = $this->getConfiguration(); + $config = $this->getConfig()->getOptions(); $config['basepath'] = $config['basepath'] ?? '.'; $arguments->addOptionalCommaSeparatedArgument('--standard=%s', (array) $config['standard']); $arguments->addOptionalCommaSeparatedArgument('--extensions=%s', (array) $config['extensions']); diff --git a/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php b/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php index ac6f41a..07d4f30 100644 --- a/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php +++ b/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php @@ -19,7 +19,7 @@ class PhpstanCheckDeprecationTask extends AbstractMultiPathProcessingTask { */ public function buildArguments(iterable $files): ProcessArgumentsCollection { $arguments = $this->processBuilder->createArgumentsForCommand('phpstan'); - $config = $this->getConfiguration(); + $config = $this->getConfig()->getOptions(); $arguments->add('analyse'); $arguments->addOptionalArgument('--autoload-file=%s', $config['autoload_file']); $arguments->addOptionalArgument('--configuration=%s', $config['configuration']); diff --git a/src/Task/YamlLint/YamlLintTask.php b/src/Task/YamlLint/YamlLintTask.php index ce3e670..5d3db7f 100644 --- a/src/Task/YamlLint/YamlLintTask.php +++ b/src/Task/YamlLint/YamlLintTask.php @@ -18,7 +18,7 @@ class YamlLintTask extends AbstractLintTask { * {@inheritdoc} */ public function configureLint(LinterInterface $linter): void { - $config = $this->getConfiguration(); + $config = $this->getConfig()->getOptions(); $linter->setObjectSupport($config['object_support']); $linter->setExceptionOnInvalidType($config['exception_on_invalid_type']); $linter->setParseCustomTags($config['parse_custom_tags']); diff --git a/src/Task/tasks.yml b/src/Task/tasks.yml index 4fbedd6..695e4ad 100644 --- a/src/Task/tasks.yml +++ b/src/Task/tasks.yml @@ -3,7 +3,6 @@ default: name: default is_file_specific: false arguments: - - config - process_builder - formatter.raw_process options: @@ -113,7 +112,6 @@ Wunderio\GrumPHP\Task\PhpCompatibility\PhpCompatibilityTask: allowed_types: ['string'] Wunderio\GrumPHP\Task\Phpcs\PhpcsTask: arguments: - - config - process_builder - formatter.phpcs options: @@ -198,7 +196,6 @@ Wunderio\GrumPHP\Task\PhpstanCheckDeprecation\PhpstanCheckDeprecationTask: Wunderio\GrumPHP\Task\YamlLint\YamlLintTask: is_file_specific: true arguments: - - config - linter.yamllint options: ignore_patterns: @@ -230,7 +227,6 @@ Wunderio\GrumPHP\Task\YamlLint\YamlLintTask: Wunderio\GrumPHP\Task\JsonLint\JsonLintTask: is_file_specific: true arguments: - - config - linter.jsonlint options: ignore_patterns: From 13798d212815175bc5cf784bf28515bb3db8170d Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:42:06 +0200 Subject: [PATCH 08/13] Updated tests --- tests/AbstractExternalExtensionLoaderTest.php | 54 +------------------ tests/AbstractLintTaskTest.php | 18 +++---- tests/AbstractMultiPathProcessingTaskTest.php | 4 -- tests/AbstractProcessingTaskTest.php | 3 -- .../AbstractSinglePathProcessingTaskTest.php | 5 -- .../CheckFilePermissionsTaskTest.php | 2 - tests/Ecs/EcsTaskTest.php | 7 +-- tests/JsonLint/JsonLintTaskTest.php | 5 +- .../PhpCheckSyntax/PhpCheckSyntaxTaskTest.php | 7 +-- .../PhpCompatibilityTaskTest.php | 7 +-- tests/Phpcs/PhpcsTaskTest.php | 9 ++-- .../PhpstanCheckDeprecationTaskTest.php | 11 ++-- tests/YamlLint/YamlLintTaskTest.php | 5 +- 13 files changed, 41 insertions(+), 96 deletions(-) diff --git a/tests/AbstractExternalExtensionLoaderTest.php b/tests/AbstractExternalExtensionLoaderTest.php index c06a47d..93254dc 100644 --- a/tests/AbstractExternalExtensionLoaderTest.php +++ b/tests/AbstractExternalExtensionLoaderTest.php @@ -8,10 +8,7 @@ declare(strict_types = 1); use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\DependencyInjection\Reference; use Wunderio\GrumPHP\Task\AbstractExternalExtensionLoader; -use Symfony\Component\DependencyInjection\ContainerBuilder; /** * Class AbstractExternalExtensionLoaderTest. @@ -26,59 +23,10 @@ final class AbstractExternalExtensionLoaderTest extends TestCase { public function testSetsConfigurationFromYaml(): void { $customLoader = new CustomTestExtensionLoader(); $this->assertEquals('custom_test', $customLoader->name); - $this->assertEquals(['config', 'process_builder', 'formatter.raw_process'], $customLoader->arguments); + $this->assertEquals(['process_builder', 'formatter.raw_process'], $customLoader->arguments); $this->assertEquals('CustomTestTask', $customLoader->class); } - /** - * Test load. - * - * @covers \Wunderio\GrumPHP\Task\AbstractExternalExtensionLoader::load - */ - public function testLoadsDefinitionWithArguments(): void { - $class = AbstractMultiPathProcessingTaskTest::class; - $stub = $this->getMockBuilder(AbstractExternalExtensionLoader::class) - ->setMethodsExcept(['load']) - ->getMockForAbstractClass(); - $container = $this->createMock(ContainerBuilder::class); - - $container->expects($this->once()) - ->method('register') - ->willReturn(new Definition($class)); - - /** @var \Symfony\Component\DependencyInjection\Definition $task */ - $task = $stub->load($container); - $this->assertInstanceOf(Definition::class, $task); - $this->assertInstanceOf(Reference::class, $task->getArguments()[0]); - $this->assertInstanceOf(Reference::class, $task->getArguments()[1]); - $this->assertInstanceOf(Reference::class, $task->getArguments()[2]); - $this->assertEquals($class, $task->getClass()); - } - - /** - * Test load without arguments. - * - * @covers \Wunderio\GrumPHP\Task\AbstractExternalExtensionLoader::load - */ - public function testLoadsDefinitionWithoutArguments(): void { - $class = AbstractMultiPathProcessingTaskTest::class; - $stub = $this->getMockBuilder(AbstractExternalExtensionLoader::class) - ->setMethodsExcept(['load']) - ->getMockForAbstractClass(); - $container = $this->createMock(ContainerBuilder::class); - - $container->expects($this->once()) - ->method('register') - ->willReturn(new Definition($class)); - $stub->arguments = []; - - /** @var \Symfony\Component\DependencyInjection\Definition $task */ - $task = $stub->load($container); - $this->assertInstanceOf(Definition::class, $task); - $this->assertEquals([], $task->getArguments()); - $this->assertEquals($class, $task->getClass()); - } - } /** diff --git a/tests/AbstractLintTaskTest.php b/tests/AbstractLintTaskTest.php index 478e42e..9291b58 100644 --- a/tests/AbstractLintTaskTest.php +++ b/tests/AbstractLintTaskTest.php @@ -9,10 +9,10 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\LintErrorsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Linter\LinterInterface; use GrumPHP\Linter\LintError; use GrumPHP\Runner\TaskResult; +use GrumPHP\Task\Config\TaskConfigInterface; use GrumPHP\Task\Context\ContextInterface; use GrumPHP\Task\TaskInterface; use PHPUnit\Framework\TestCase; @@ -30,7 +30,6 @@ final class AbstractLintTaskTest extends TestCase { */ public function testSetsConfigurationFromYaml(): void { $customTask = new CustomLintTestTask( - $this->createMock(GrumPHP::class), $this->createMock(LinterInterface::class) ); $this->assertEquals('custom_lint_test', $customTask->name); @@ -45,7 +44,6 @@ public function testSetsConfigurationFromYaml(): void { public function testPassesTaskIfProcessSuccessful(): void { $stub = $this->getMockBuilder(AbstractLintTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $this->createMock(LinterInterface::class), ]) ->setMethodsExcept(['run']) @@ -71,7 +69,6 @@ public function testPassesTaskIfProcessSuccessful(): void { public function testSkipsIfNoFilesFound(): void { $stub = $this->getMockBuilder(AbstractLintTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $this->createMock(LinterInterface::class), ]) ->setMethodsExcept(['run']) @@ -97,7 +94,6 @@ public function testReturnsFailedResultOnException(): void { $lint = $this->createMock(LinterInterface::class); $stub = $this->getMockBuilder(AbstractLintTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $lint, ]) ->setMethodsExcept(['runLint']) @@ -119,17 +115,19 @@ public function testReturnsFailedResultOnLintError(): void { $lint = $this->createMock(LinterInterface::class); $stub = $this->getMockBuilder(AbstractLintTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $lint, ]) ->setMethodsExcept(['runLint']) ->getMockForAbstractClass(); + $taskConfig = $this->createMock(TaskConfigInterface::class); + $files = new FilesCollection([new SplFileInfo(__FILE__)]); $lintError = new LintErrorsCollection([ new LintError('Error', 'TestError', __FILE__, 1), ]); - $stub->method('getConfiguration')->willReturn(['ignore_patterns' => []]); + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn(['ignore_patterns' => []]); $lint->method('isInstalled')->willReturn(TRUE); $lint->expects($this->once())->method('lint')->willReturn($lintError); @@ -146,15 +144,17 @@ public function testReturnsSuccessResultOnSuccess(): void { $lint = $this->createMock(LinterInterface::class); $stub = $this->getMockBuilder(AbstractLintTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $lint, ]) ->setMethodsExcept(['runLint']) ->getMockForAbstractClass(); + $taskConfig = $this->createMock(TaskConfigInterface::class); + $files = new FilesCollection([new SplFileInfo(__FILE__)]); $lintError = new LintErrorsCollection([]); - $stub->method('getConfiguration')->willReturn(['ignore_patterns' => []]); + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn(['ignore_patterns' => []]); $lint->method('isInstalled')->willReturn(TRUE); $lint->expects($this->once())->method('lint')->willReturn($lintError); diff --git a/tests/AbstractMultiPathProcessingTaskTest.php b/tests/AbstractMultiPathProcessingTaskTest.php index 28b3ef3..25945e7 100644 --- a/tests/AbstractMultiPathProcessingTaskTest.php +++ b/tests/AbstractMultiPathProcessingTaskTest.php @@ -8,7 +8,6 @@ declare(strict_types = 1); use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; use GrumPHP\Runner\TaskResult; @@ -31,7 +30,6 @@ final class AbstractMultiPathProcessingTaskTest extends TestCase { * @covers \Wunderio\GrumPHP\Task\AbstractMultiPathProcessingTask::run */ public function testSkipsTaskIfNoFilesFound(): void { - $grumPHP = $this->createMock(GrumPHP::class); $processBuilder = $this->getMockBuilder(ProcessBuilder::class) ->disableOriginalConstructor() ->onlyMethods(['buildProcess']) @@ -39,7 +37,6 @@ public function testSkipsTaskIfNoFilesFound(): void { $processFormatterInterface = $this->createMock(ProcessFormatterInterface::class); $stub = $this->getMockBuilder(AbstractMultiPathProcessingTask::class) ->setConstructorArgs([ - $grumPHP, $processBuilder, $processFormatterInterface, ]) @@ -69,7 +66,6 @@ public function testReturnsTaskResultIfFileFoundAndProcessUnsuccessful(): void { ->getMock(); $stub = $this->getMockBuilder(AbstractMultiPathProcessingTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) diff --git a/tests/AbstractProcessingTaskTest.php b/tests/AbstractProcessingTaskTest.php index f31f8ac..b1b1fac 100644 --- a/tests/AbstractProcessingTaskTest.php +++ b/tests/AbstractProcessingTaskTest.php @@ -7,7 +7,6 @@ declare(strict_types = 1); -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; use GrumPHP\Runner\TaskResultInterface; @@ -28,7 +27,6 @@ final class AbstractProcessingTaskTest extends TestCase { */ public function testSetsConfigurationFromYaml(): void { $customTask = new CustomTestTask( - $this->createMock(GrumPHP::class), $this->createMock(ProcessBuilder::class), $this->createMock(ProcessFormatterInterface::class) ); @@ -46,7 +44,6 @@ public function testFailsTaskIfProcessUnsuccessful(): void { $processFormatterInterface->expects($this->once())->method('format')->willReturn('Formatted Output.'); $stub = $this->getMockBuilder(AbstractProcessingTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $this->createMock(ProcessBuilder::class), $processFormatterInterface, ]) diff --git a/tests/AbstractSinglePathProcessingTaskTest.php b/tests/AbstractSinglePathProcessingTaskTest.php index 8b9f4e6..ecd96ed 100644 --- a/tests/AbstractSinglePathProcessingTaskTest.php +++ b/tests/AbstractSinglePathProcessingTaskTest.php @@ -9,7 +9,6 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; use GrumPHP\Runner\TaskResult; @@ -65,12 +64,10 @@ final class AbstractSinglePathProcessingTaskTest extends TestCase { * {@inheritdoc} */ public function setUp(): void { - $this->grumPHP = $this->createMock(GrumPHP::class); $this->processBuilder = $this->createMock(ProcessBuilder::class); $this->processFormatterInterface = $this->createMock(ProcessFormatterInterface::class); $this->stub = $this->getMockBuilder(AbstractSinglePathProcessingTask::class) ->setConstructorArgs([ - $this->grumPHP, $this->processBuilder, $this->processFormatterInterface, ]) @@ -143,7 +140,6 @@ public function testFailsTaskIfMultipleFilesFoundButProcessUnsuccessful(): void public function testRunsPathListInParallel(): void { $task = $this->getMockBuilder(AbstractSinglePathProcessingTask::class) ->setConstructorArgs([ - $this->grumPHP, $this->processBuilder, $this->processFormatterInterface, ]) @@ -176,7 +172,6 @@ static function (&$runningProcesses, &$output) use ($output_text) { public function testHandlesParallelProcess(): void { $task = $this->getMockBuilder(AbstractSinglePathProcessingTask::class) ->setConstructorArgs([ - $this->grumPHP, $this->processBuilder, $this->processFormatterInterface, ]) diff --git a/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php b/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php index 8679c3a..8d27daa 100644 --- a/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php +++ b/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php @@ -9,7 +9,6 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; use PHPUnit\Framework\TestCase; @@ -29,7 +28,6 @@ public function testBuildsProcessArguments(): void { $processBuilder = $this->createMock(ProcessBuilder::class); $stub = $this->getMockBuilder(CheckFilePermissionsTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) diff --git a/tests/Ecs/EcsTaskTest.php b/tests/Ecs/EcsTaskTest.php index 41d1fa0..f002f16 100644 --- a/tests/Ecs/EcsTaskTest.php +++ b/tests/Ecs/EcsTaskTest.php @@ -9,9 +9,9 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Wunderio\GrumPHP\Task\Ecs\EcsTask; @@ -29,13 +29,13 @@ public function testBuildsProcessArguments(): void { $processBuilder = $this->createMock(ProcessBuilder::class); $stub = $this->getMockBuilder(EcsTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) ->setMethodsExcept(['buildArguments']) ->getMock(); $arguments = $this->createMock(ProcessArgumentsCollection::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); $files = new FilesCollection(['file.php']); $processBuilder->expects($this->once())->method('createArgumentsForCommand')->willReturn($arguments); @@ -48,7 +48,8 @@ public function testBuildsProcessArguments(): void { 'no-progress-bar' => TRUE, 'level' => NULL, ]; - $stub->method('getConfiguration')->willReturn($config); + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn($config); $actual = $stub->buildArguments($files); $this->assertInstanceOf(ProcessArgumentsCollection::class, $actual); diff --git a/tests/JsonLint/JsonLintTaskTest.php b/tests/JsonLint/JsonLintTaskTest.php index b7a636e..ddb9943 100644 --- a/tests/JsonLint/JsonLintTaskTest.php +++ b/tests/JsonLint/JsonLintTaskTest.php @@ -8,6 +8,7 @@ declare(strict_types = 1); use GrumPHP\Linter\Json\JsonLinter; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Wunderio\GrumPHP\Task\JsonLint\JsonLintTask; @@ -27,8 +28,10 @@ public function testBuildsProcessArgumentsFromPath(): void { ->setMethodsExcept(['configureLint']) ->getMock(); $lint = $this->createMock(JsonLinter::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); - $stub->method('getConfiguration')->willReturn($this->getConfigDefaults()); + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn($this->getConfigDefaults()); $lint->expects($this->once())->method('setDetectKeyConflicts'); $stub->configureLint($lint); diff --git a/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php b/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php index 040ff22..9818832 100644 --- a/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php +++ b/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php @@ -8,9 +8,9 @@ declare(strict_types = 1); use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Wunderio\GrumPHP\Task\PhpCheckSyntax\PhpCheckSyntaxTask; @@ -28,13 +28,13 @@ public function testBuildsProcessArgumentsFromPath(): void { $processBuilder = $this->createMock(ProcessBuilder::class); $stub = $this->getMockBuilder(PhpCheckSyntaxTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) ->setMethodsExcept(['buildArgumentsFromPath']) ->getMock(); $arguments = $this->createMock(ProcessArgumentsCollection::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); $path = 'test.php'; $processBuilder->expects($this->once()) @@ -42,7 +42,8 @@ public function testBuildsProcessArgumentsFromPath(): void { ->willReturn($arguments); $arguments->expects($this->exactly(2)) ->method('add'); - $stub->method('getConfiguration')->willReturn($this->getConfigDefaults()); + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn($this->getConfigDefaults()); $actual = $stub->buildArgumentsFromPath($path); $this->assertInstanceOf(ProcessArgumentsCollection::class, $actual); diff --git a/tests/PhpCompatibility/PhpCompatibilityTaskTest.php b/tests/PhpCompatibility/PhpCompatibilityTaskTest.php index dde7753..c1496cd 100644 --- a/tests/PhpCompatibility/PhpCompatibilityTaskTest.php +++ b/tests/PhpCompatibility/PhpCompatibilityTaskTest.php @@ -9,9 +9,9 @@ use GrumPHP\Collection\FilesCollection; use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Wunderio\GrumPHP\Task\PhpCompatibility\PhpCompatibilityTask; @@ -29,20 +29,21 @@ public function testBuildsProcessArguments(): void { $processBuilder = $this->createMock(ProcessBuilder::class); $stub = $this->getMockBuilder(PhpCompatibilityTask::class) ->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) ->setMethodsExcept(['buildArguments']) ->getMock(); $arguments = $this->createMock(ProcessArgumentsCollection::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); $files = new FilesCollection(['test.php', 'file.php']); $processBuilder->method('createArgumentsForCommand') ->willReturn($arguments); $arguments->expects($this->exactly(5)) ->method('add'); - $stub->method('getConfiguration')->willReturn([ + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn([ 'standard' => 'php-compatibility.xm', 'testVersion' => '7.3', 'extensions' => ['php'], diff --git a/tests/Phpcs/PhpcsTaskTest.php b/tests/Phpcs/PhpcsTaskTest.php index 6b81351..dfe2ebc 100644 --- a/tests/Phpcs/PhpcsTaskTest.php +++ b/tests/Phpcs/PhpcsTaskTest.php @@ -8,15 +8,15 @@ declare(strict_types = 1); use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Symfony\Component\Yaml\Yaml; use Wunderio\GrumPHP\Task\Phpcs\PhpcsTask; /** - * Class PhpCompatibilityTaskTest. + * Class PhpcsTaskTest. */ final class PhpcsTaskTest extends TestCase { @@ -28,12 +28,12 @@ final class PhpcsTaskTest extends TestCase { public function testBuildsProcessArguments(): void { $processBuilder = $this->createMock(ProcessBuilder::class); $stub = $this->getMockBuilder(PhpcsTask::class)->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) ->setMethodsExcept(['buildArguments'])->getMock(); $arguments = $this->createMock(ProcessArgumentsCollection::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); $files = ['file1.php', 'file2.php', 'file3.php', 'dir1/']; $processBuilder->expects($this->once()) @@ -44,7 +44,8 @@ public function testBuildsProcessArguments(): void { foreach ($this->getConfigurations() as $name => $option) { $config[$name] = $option['defaults']; } - $stub->expects($this->once())->method('getConfiguration')->willReturn($config); + $stub->expects($this->once())->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn($config); $actual = $stub->buildArguments($files); $this->assertInstanceOf(ProcessArgumentsCollection::class, $actual); diff --git a/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php b/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php index 9ebd3cb..cf70bb4 100644 --- a/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php +++ b/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php @@ -8,32 +8,32 @@ declare(strict_types = 1); use GrumPHP\Collection\ProcessArgumentsCollection; -use GrumPHP\Configuration\GrumPHP; use GrumPHP\Formatter\ProcessFormatterInterface; use GrumPHP\Process\ProcessBuilder; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Symfony\Component\Yaml\Yaml; use Wunderio\GrumPHP\Task\PhpstanCheckDeprecation\PhpstanCheckDeprecationTask; /** - * Class PhpstanTaskTest. + * Class PhpstanCheckDeprecationTaskTest. */ final class PhpstanCheckDeprecationTaskTest extends TestCase { /** * Test building arguments. * - * @covers \Wunderio\GrumPHP\Task\Phpstan\PhpstanDrupalCheckTask::buildArguments + * @covers \Wunderio\GrumPHP\Task\PhpstanCheckDeprecation\PhpstanCheckDeprecationTask::buildArguments */ public function testBuildsProcessArguments(): void { $processBuilder = $this->createMock(ProcessBuilder::class); $stub = $this->getMockBuilder(PhpstanCheckDeprecationTask::class)->setConstructorArgs([ - $this->createMock(GrumPHP::class), $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) ->setMethodsExcept(['buildArguments'])->getMock(); $arguments = $this->createMock(ProcessArgumentsCollection::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); $files = ['file1.php', 'file2.php', 'dir1/']; $processBuilder->expects($this->once()) @@ -45,7 +45,8 @@ public function testBuildsProcessArguments(): void { foreach ($this->getConfigurations() as $name => $option) { $config[$name] = $option['defaults']; } - $stub->expects($this->once())->method('getConfiguration')->willReturn($config); + $stub->expects($this->once())->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn($config); $actual = $stub->buildArguments($files); $this->assertInstanceOf(ProcessArgumentsCollection::class, $actual); diff --git a/tests/YamlLint/YamlLintTaskTest.php b/tests/YamlLint/YamlLintTaskTest.php index bd13286..c537a51 100644 --- a/tests/YamlLint/YamlLintTaskTest.php +++ b/tests/YamlLint/YamlLintTaskTest.php @@ -8,6 +8,7 @@ declare(strict_types = 1); use GrumPHP\Linter\Yaml\YamlLinter; +use GrumPHP\Task\Config\TaskConfigInterface; use PHPUnit\Framework\TestCase; use Wunderio\GrumPHP\Task\YamlLint\YamlLintTask; @@ -27,8 +28,10 @@ public function testBuildsProcessArgumentsFromPath(): void { ->setMethodsExcept(['configureLint']) ->getMock(); $lint = $this->createMock(YamlLinter::class); + $taskConfig = $this->createMock(TaskConfigInterface::class); - $stub->method('getConfiguration')->willReturn($this->getConfigDefaults()); + $stub->method('getConfig')->willReturn($taskConfig); + $taskConfig->method('getOptions')->willReturn($this->getConfigDefaults()); $lint->expects($this->once())->method('setObjectSupport'); $lint->expects($this->once())->method('setExceptionOnInvalidType'); $lint->expects($this->once())->method('setParseCustomTags'); From bb418fda2649c5dfaa281e9ec346ed334a26eb32 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 08:43:34 +0200 Subject: [PATCH 09/13] Put tasks and other grumphp related configuration under grumphp --- config/grumphp.yml | 2 +- grumphp.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/grumphp.yml b/config/grumphp.yml index 2b3d25c..9abf90c 100644 --- a/config/grumphp.yml +++ b/config/grumphp.yml @@ -1,4 +1,4 @@ -parameters: +grumphp: stop_on_failure: true ascii: failed: ~ diff --git a/grumphp.yml b/grumphp.yml index 187554b..501e5ec 100755 --- a/grumphp.yml +++ b/grumphp.yml @@ -1,4 +1,4 @@ -parameters: +grumphp: stop_on_failure: true ascii: failed: ~ From 61a3db61103298ad5f5a0d0d72a12d7ff79d94c2 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Mon, 30 Nov 2020 21:58:40 +0200 Subject: [PATCH 10/13] Fixed phpcs warning and error notifications --- src/Task/AbstractExternalExtensionLoader.php | 2 ++ src/Task/AbstractLintTask.php | 3 +++ src/Task/AbstractMultiPathProcessingTask.php | 2 ++ src/Task/AbstractProcessingTask.php | 17 +++++++++++++---- src/Task/AbstractSinglePathProcessingTask.php | 2 ++ .../CheckFilePermissionsExtensionLoader.php | 2 ++ .../CheckFilePermissionsTask.php | 2 ++ src/Task/ConfigurableTaskInterface.php | 2 ++ src/Task/ConfigurableTaskTrait.php | 16 +++++++++++----- src/Task/ContextRunTrait.php | 2 ++ src/Task/Ecs/EcsExtensionLoader.php | 2 ++ src/Task/Ecs/EcsTask.php | 2 ++ src/Task/JsonLint/JsonLintExtensionLoader.php | 2 ++ src/Task/JsonLint/JsonLintTask.php | 2 ++ src/Task/LintTaskInterface.php | 2 ++ src/Task/MultiPathArgumentsBuilderInterface.php | 2 ++ .../PhpCheckSyntaxExtensionLoader.php | 2 ++ src/Task/PhpCheckSyntax/PhpCheckSyntaxTask.php | 2 ++ .../PhpCompatibilityExtensionLoader.php | 2 ++ .../PhpCompatibility/PhpCompatibilityTask.php | 10 +++++++++- src/Task/Phpcs/PhpcsExtensionLoader.php | 2 ++ src/Task/Phpcs/PhpcsTask.php | 2 ++ .../PhpstanCheckDeprecationExtensionLoader.php | 2 ++ .../PhpstanCheckDeprecationTask.php | 2 ++ .../SinglePathArgumentsBuilderInterface.php | 2 ++ src/Task/YamlLint/YamlLintExtensionLoader.php | 2 ++ src/Task/YamlLint/YamlLintTask.php | 2 ++ tests/AbstractExternalExtensionLoaderTest.php | 2 ++ tests/AbstractLintTaskTest.php | 2 ++ tests/AbstractMultiPathProcessingTaskTest.php | 2 ++ tests/AbstractProcessingTaskTest.php | 2 ++ tests/AbstractSinglePathProcessingTaskTest.php | 2 ++ .../CheckFilePermissionsTaskTest.php | 2 ++ tests/ConfigurableTaskTraitTest.php | 2 ++ tests/ContextRunTraitTest.php | 2 ++ tests/Ecs/EcsTaskTest.php | 2 ++ tests/JsonLint/JsonLintTaskTest.php | 2 ++ tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php | 2 ++ .../PhpCompatibilityTaskTest.php | 2 ++ tests/Phpcs/PhpcsTaskTest.php | 2 ++ .../PhpstanCheckDeprecationTaskTest.php | 2 ++ tests/YamlLint/YamlLintTaskTest.php | 2 ++ 42 files changed, 112 insertions(+), 10 deletions(-) diff --git a/src/Task/AbstractExternalExtensionLoader.php b/src/Task/AbstractExternalExtensionLoader.php index 891fd49..7aad7d9 100644 --- a/src/Task/AbstractExternalExtensionLoader.php +++ b/src/Task/AbstractExternalExtensionLoader.php @@ -12,6 +12,8 @@ /** * Class AbstractExternalExtensionLoader. * + * Provides a base implementation for \GrumPHP\Extension\ExtensionInterface. + * * @package Wunderio\GrumPHP\Task */ abstract class AbstractExternalExtensionLoader implements ExtensionInterface { diff --git a/src/Task/AbstractLintTask.php b/src/Task/AbstractLintTask.php index 77b2265..dbbf74c 100644 --- a/src/Task/AbstractLintTask.php +++ b/src/Task/AbstractLintTask.php @@ -15,6 +15,8 @@ /** * Class AbstractLintTask. * + * Provides a base implementation for lint tasks. + * * @package Wunderio\GrumPHP\Task */ abstract class AbstractLintTask extends AbstractLinterTask implements LintTaskInterface, ConfigurableTaskInterface { @@ -26,6 +28,7 @@ abstract class AbstractLintTask extends AbstractLinterTask implements LintTaskIn * AbstractLintTask constructor. * * @param \GrumPHP\Linter\LinterInterface $linter + * Linter. */ public function __construct(LinterInterface $linter) { parent::__construct($linter); diff --git a/src/Task/AbstractMultiPathProcessingTask.php b/src/Task/AbstractMultiPathProcessingTask.php index ae4a5c0..78a1e7b 100644 --- a/src/Task/AbstractMultiPathProcessingTask.php +++ b/src/Task/AbstractMultiPathProcessingTask.php @@ -10,6 +10,8 @@ /** * Class AbstractMultiPathProcessingTask. * + * Provides a base implementation for processing task with multiple paths. + * * @package Wunderio\GrumPHP\Task */ abstract class AbstractMultiPathProcessingTask extends AbstractProcessingTask implements MultiPathArgumentsBuilderInterface { diff --git a/src/Task/AbstractProcessingTask.php b/src/Task/AbstractProcessingTask.php index 2948661..4782e97 100644 --- a/src/Task/AbstractProcessingTask.php +++ b/src/Task/AbstractProcessingTask.php @@ -16,6 +16,8 @@ /** * Class AbstractProcessingTask. * + * Provides a base implementation for processing task. + * * @package Wunderio\GrumPHP\Task */ abstract class AbstractProcessingTask extends AbstractExternalTask implements ConfigurableTaskInterface { @@ -27,7 +29,9 @@ abstract class AbstractProcessingTask extends AbstractExternalTask implements Co * AbstractProcessingTask constructor. * * @param \GrumPHP\Process\ProcessBuilder $processBuilder + * Process builder. * @param \GrumPHP\Formatter\ProcessFormatterInterface $formatter + * Formatter. */ public function __construct(ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter) { parent::__construct($processBuilder, $formatter); @@ -55,16 +59,21 @@ public function getTaskResult(Process $process, ContextInterface $context): Task return TaskResult::createPassed($this, $context); } - public function getConfig(): TaskConfigInterface - { + /** + * {@inheritdoc} + */ + public function getConfig(): TaskConfigInterface { return $this->config; } - public function withConfig(TaskConfigInterface $config): TaskInterface - { + /** + * {@inheritdoc} + */ + public function withConfig(TaskConfigInterface $config): TaskInterface { $new = clone $this; $new->config = $config; return $new; } + } diff --git a/src/Task/AbstractSinglePathProcessingTask.php b/src/Task/AbstractSinglePathProcessingTask.php index 9111fd8..96107c7 100644 --- a/src/Task/AbstractSinglePathProcessingTask.php +++ b/src/Task/AbstractSinglePathProcessingTask.php @@ -12,6 +12,8 @@ /** * Class AbstractSinglePathProcessingTask. * + * Provides a base implementation for processing task with single path. + * * @package Wunderio\GrumPHP\Task */ abstract class AbstractSinglePathProcessingTask extends AbstractProcessingTask implements SinglePathArgumentsBuilderInterface { diff --git a/src/Task/CheckFilePermissions/CheckFilePermissionsExtensionLoader.php b/src/Task/CheckFilePermissions/CheckFilePermissionsExtensionLoader.php index df102b1..254ab8a 100644 --- a/src/Task/CheckFilePermissions/CheckFilePermissionsExtensionLoader.php +++ b/src/Task/CheckFilePermissions/CheckFilePermissionsExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class CheckFilePermissionsExtensionLoader. * + * Register CheckFilePermissions task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class CheckFilePermissionsExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/CheckFilePermissions/CheckFilePermissionsTask.php b/src/Task/CheckFilePermissions/CheckFilePermissionsTask.php index a506664..55ffa0c 100644 --- a/src/Task/CheckFilePermissions/CheckFilePermissionsTask.php +++ b/src/Task/CheckFilePermissions/CheckFilePermissionsTask.php @@ -10,6 +10,8 @@ /** * Class CheckFilePermissionsTask. * + * CheckFilePermissions task. + * * @package Wunderio\GrumPHP\Task */ class CheckFilePermissionsTask extends AbstractMultiPathProcessingTask { diff --git a/src/Task/ConfigurableTaskInterface.php b/src/Task/ConfigurableTaskInterface.php index a0a3e38..7af95e2 100644 --- a/src/Task/ConfigurableTaskInterface.php +++ b/src/Task/ConfigurableTaskInterface.php @@ -9,6 +9,8 @@ /** * Interface ConfigurableTaskInterface. * + * Defines the interface for class that extends \GrumPHP\Task\TaskInterface. + * * @package Wunderio\GrumPHP\Task */ interface ConfigurableTaskInterface extends TaskInterface { diff --git a/src/Task/ConfigurableTaskTrait.php b/src/Task/ConfigurableTaskTrait.php index 30b8ca5..0ca4376 100644 --- a/src/Task/ConfigurableTaskTrait.php +++ b/src/Task/ConfigurableTaskTrait.php @@ -15,6 +15,8 @@ /** * Trait ConfigurableTaskTrait. * + * Trait for \GrumPHP\Task\TaskInterface. + * * @package Wunderio\GrumPHP\Task */ trait ConfigurableTaskTrait { @@ -43,7 +45,7 @@ trait ConfigurableTaskTrait { /** * Configurable options. * - * @var TaskConfigInterface + * @var \GrumPHP\Task\Config\TaskConfigInterface */ public $configuration; @@ -69,8 +71,10 @@ public function getName(): string { return $this->name; } - public function getConfig(): TaskConfigInterface - { + /** + * {@inheritdoc} + */ + public function getConfig(): TaskConfigInterface { return $this->config; } @@ -99,8 +103,10 @@ public static function getConfigurableOptions(): OptionsResolver { return $resolver; } - public function withConfig(TaskConfigInterface $config): TaskInterface - { + /** + * {@inheritdoc} + */ + public function withConfig(TaskConfigInterface $config): TaskInterface { $new = clone $this; $new->config = $config; diff --git a/src/Task/ContextRunTrait.php b/src/Task/ContextRunTrait.php index bad0806..22ae9d0 100644 --- a/src/Task/ContextRunTrait.php +++ b/src/Task/ContextRunTrait.php @@ -9,6 +9,8 @@ /** * Trait ContextRunTrait. * + * Trait for \GrumPHP\Task\TaskInterface. + * * @package Wunderio\GrumPHP\Task */ trait ContextRunTrait { diff --git a/src/Task/Ecs/EcsExtensionLoader.php b/src/Task/Ecs/EcsExtensionLoader.php index 6455b24..b31ca0d 100644 --- a/src/Task/Ecs/EcsExtensionLoader.php +++ b/src/Task/Ecs/EcsExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class EcsExtensionLoader. * + * Register Ecs task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class EcsExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/Ecs/EcsTask.php b/src/Task/Ecs/EcsTask.php index 63541f2..745b6ee 100644 --- a/src/Task/Ecs/EcsTask.php +++ b/src/Task/Ecs/EcsTask.php @@ -10,6 +10,8 @@ /** * Class EcsTask. * + * Ecs task. + * * @package Wunderio\GrumPHP\Task */ class EcsTask extends AbstractMultiPathProcessingTask { diff --git a/src/Task/JsonLint/JsonLintExtensionLoader.php b/src/Task/JsonLint/JsonLintExtensionLoader.php index 9d9dd89..d0a51d7 100644 --- a/src/Task/JsonLint/JsonLintExtensionLoader.php +++ b/src/Task/JsonLint/JsonLintExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class JsonLintExtensionLoader. * + * Register JsonLint task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class JsonLintExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/JsonLint/JsonLintTask.php b/src/Task/JsonLint/JsonLintTask.php index 2166e1b..c990140 100644 --- a/src/Task/JsonLint/JsonLintTask.php +++ b/src/Task/JsonLint/JsonLintTask.php @@ -10,6 +10,8 @@ /** * Class JsonLintTask. * + * JsonLint task. + * * @package Wunderio\GrumPHP\Task */ class JsonLintTask extends AbstractLintTask { diff --git a/src/Task/LintTaskInterface.php b/src/Task/LintTaskInterface.php index 5dcfc41..bcce9be 100644 --- a/src/Task/LintTaskInterface.php +++ b/src/Task/LintTaskInterface.php @@ -9,6 +9,8 @@ /** * Interface LintTaskInterface. * + * Defines the interface for lint task. + * * @package Wunderio\GrumPHP\Task */ interface LintTaskInterface { diff --git a/src/Task/MultiPathArgumentsBuilderInterface.php b/src/Task/MultiPathArgumentsBuilderInterface.php index ed82830..2a3b74e 100644 --- a/src/Task/MultiPathArgumentsBuilderInterface.php +++ b/src/Task/MultiPathArgumentsBuilderInterface.php @@ -9,6 +9,8 @@ /** * Interface MultiPathArgumentsBuilderInterface. * + * Defines the interface for building Process arguments for multiple paths. + * * @package Wunderio\GrumPHP\Task */ interface MultiPathArgumentsBuilderInterface { diff --git a/src/Task/PhpCheckSyntax/PhpCheckSyntaxExtensionLoader.php b/src/Task/PhpCheckSyntax/PhpCheckSyntaxExtensionLoader.php index 68473a0..fa829e7 100644 --- a/src/Task/PhpCheckSyntax/PhpCheckSyntaxExtensionLoader.php +++ b/src/Task/PhpCheckSyntax/PhpCheckSyntaxExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class PhpCheckSyntaxExtensionLoader. * + * Register PhpCheckSyntax task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class PhpCheckSyntaxExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/PhpCheckSyntax/PhpCheckSyntaxTask.php b/src/Task/PhpCheckSyntax/PhpCheckSyntaxTask.php index f4e85f9..cab8287 100644 --- a/src/Task/PhpCheckSyntax/PhpCheckSyntaxTask.php +++ b/src/Task/PhpCheckSyntax/PhpCheckSyntaxTask.php @@ -10,6 +10,8 @@ /** * Class PhpCheckSyntaxTask. * + * PhpCheckSyntax task. + * * @package Wunderio\GrumPHP\Task */ class PhpCheckSyntaxTask extends AbstractSinglePathProcessingTask { diff --git a/src/Task/PhpCompatibility/PhpCompatibilityExtensionLoader.php b/src/Task/PhpCompatibility/PhpCompatibilityExtensionLoader.php index 09105e1..fb084a6 100644 --- a/src/Task/PhpCompatibility/PhpCompatibilityExtensionLoader.php +++ b/src/Task/PhpCompatibility/PhpCompatibilityExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class PhpCompatibilityExtensionLoader. * + * Register PhpCompatibility task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class PhpCompatibilityExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/PhpCompatibility/PhpCompatibilityTask.php b/src/Task/PhpCompatibility/PhpCompatibilityTask.php index 4ce0310..56ad855 100644 --- a/src/Task/PhpCompatibility/PhpCompatibilityTask.php +++ b/src/Task/PhpCompatibility/PhpCompatibilityTask.php @@ -10,6 +10,8 @@ /** * Class PhpCompatibilityTask. * + * PhpCompatibility task. + * * @package Wunderio\GrumPHP\Task */ class PhpCompatibilityTask extends AbstractMultiPathProcessingTask { @@ -23,7 +25,13 @@ public function buildArguments(iterable $files): ProcessArgumentsCollection { $config['basepath'] = $config['basepath'] ?? '.'; $arguments->addOptionalCommaSeparatedArgument('--extensions=%s', (array) $config[self::D_EXT]); $arguments->addOptionalIntegerArgument('--parallel=%s', $config['parallel']); - $arguments->addSeparatedArgumentArray('--runtime-set', ['testVersion', (string) $config['testVersion']]); + $arguments->addSeparatedArgumentArray( + '--runtime-set', + [ + 'testVersion', + (string) $config['testVersion'], + ] + ); $arguments->add('--standard=' . $config['standard']); $arguments->add('--basepath=' . $config['basepath']); $arguments->add('-s'); diff --git a/src/Task/Phpcs/PhpcsExtensionLoader.php b/src/Task/Phpcs/PhpcsExtensionLoader.php index 8aa4c41..2b0cea0 100644 --- a/src/Task/Phpcs/PhpcsExtensionLoader.php +++ b/src/Task/Phpcs/PhpcsExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class PhpCompatibilityExtensionLoader. * + * Register Phpcs task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class PhpcsExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/Phpcs/PhpcsTask.php b/src/Task/Phpcs/PhpcsTask.php index 98b3c5f..cb3a0c2 100644 --- a/src/Task/Phpcs/PhpcsTask.php +++ b/src/Task/Phpcs/PhpcsTask.php @@ -10,6 +10,8 @@ /** * Class PhpCompatibilityTask. * + * Phpcs task. + * * @package Wunderio\GrumPHP\Task */ class PhpcsTask extends AbstractMultiPathProcessingTask { diff --git a/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationExtensionLoader.php b/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationExtensionLoader.php index 3ebbc1a..9570b4b 100644 --- a/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationExtensionLoader.php +++ b/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class PhpstanCheckDeprecationExtensionLoader. * + * Register PhpstanCheckDeprecation task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class PhpstanCheckDeprecationExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php b/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php index 07d4f30..1210e9e 100644 --- a/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php +++ b/src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php @@ -10,6 +10,8 @@ /** * Class PhpstanCheckDeprecationTask. * + * PhpstanCheckDeprecation task. + * * @package Wunderio\GrumPHP\Task */ class PhpstanCheckDeprecationTask extends AbstractMultiPathProcessingTask { diff --git a/src/Task/SinglePathArgumentsBuilderInterface.php b/src/Task/SinglePathArgumentsBuilderInterface.php index 845d6ae..f1e29fe 100644 --- a/src/Task/SinglePathArgumentsBuilderInterface.php +++ b/src/Task/SinglePathArgumentsBuilderInterface.php @@ -9,6 +9,8 @@ /** * Interface SinglePathArgumentsBuilderInterface. * + * Defines the interface for building Process arguments for single path. + * * @package Wunderio\GrumPHP\Task */ interface SinglePathArgumentsBuilderInterface { diff --git a/src/Task/YamlLint/YamlLintExtensionLoader.php b/src/Task/YamlLint/YamlLintExtensionLoader.php index 7d264a5..02a13db 100644 --- a/src/Task/YamlLint/YamlLintExtensionLoader.php +++ b/src/Task/YamlLint/YamlLintExtensionLoader.php @@ -7,6 +7,8 @@ /** * Class YamlLintExtensionLoader. * + * Register YamlLint task in the service container of GrumPHP. + * * @package Wunderio\GrumPHP\Task */ class YamlLintExtensionLoader extends AbstractExternalExtensionLoader {} diff --git a/src/Task/YamlLint/YamlLintTask.php b/src/Task/YamlLint/YamlLintTask.php index 5d3db7f..19a9d5a 100644 --- a/src/Task/YamlLint/YamlLintTask.php +++ b/src/Task/YamlLint/YamlLintTask.php @@ -10,6 +10,8 @@ /** * Class YamlLintTask. * + * YamlLint task. + * * @package Wunderio\GrumPHP\Task */ class YamlLintTask extends AbstractLintTask { diff --git a/tests/AbstractExternalExtensionLoaderTest.php b/tests/AbstractExternalExtensionLoaderTest.php index 93254dc..c262c0c 100644 --- a/tests/AbstractExternalExtensionLoaderTest.php +++ b/tests/AbstractExternalExtensionLoaderTest.php @@ -12,6 +12,8 @@ /** * Class AbstractExternalExtensionLoaderTest. + * + * Tests covering AbstractExternalExtensionLoader class. */ final class AbstractExternalExtensionLoaderTest extends TestCase { diff --git a/tests/AbstractLintTaskTest.php b/tests/AbstractLintTaskTest.php index 9291b58..4d8e362 100644 --- a/tests/AbstractLintTaskTest.php +++ b/tests/AbstractLintTaskTest.php @@ -20,6 +20,8 @@ /** * Class AbstractLintTaskTest. + * + * Tests covering AbstractLintTask class. */ final class AbstractLintTaskTest extends TestCase { diff --git a/tests/AbstractMultiPathProcessingTaskTest.php b/tests/AbstractMultiPathProcessingTaskTest.php index 25945e7..398d23e 100644 --- a/tests/AbstractMultiPathProcessingTaskTest.php +++ b/tests/AbstractMultiPathProcessingTaskTest.php @@ -21,6 +21,8 @@ /** * Class AbstractMultiPathProcessingTaskTest. + * + * Tests covering AbstractMultiPathProcessingTask class. */ final class AbstractMultiPathProcessingTaskTest extends TestCase { diff --git a/tests/AbstractProcessingTaskTest.php b/tests/AbstractProcessingTaskTest.php index b1b1fac..0767e03 100644 --- a/tests/AbstractProcessingTaskTest.php +++ b/tests/AbstractProcessingTaskTest.php @@ -17,6 +17,8 @@ /** * Class AbstractProcessingTaskTest. + * + * Tests covering AbstractProcessingTask class. */ final class AbstractProcessingTaskTest extends TestCase { diff --git a/tests/AbstractSinglePathProcessingTaskTest.php b/tests/AbstractSinglePathProcessingTaskTest.php index ecd96ed..b123901 100644 --- a/tests/AbstractSinglePathProcessingTaskTest.php +++ b/tests/AbstractSinglePathProcessingTaskTest.php @@ -22,6 +22,8 @@ /** * Class AbstractSinglePathProcessingTaskTest. + * + * Tests covering AbstractSinglePathProcessingTask class. */ final class AbstractSinglePathProcessingTaskTest extends TestCase { diff --git a/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php b/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php index 8d27daa..6f0f610 100644 --- a/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php +++ b/tests/CheckFilePermissions/CheckFilePermissionsTaskTest.php @@ -16,6 +16,8 @@ /** * Class CheckFilePermissionsTaskTest. + * + * Tests covering CheckFilePermissions task. */ final class CheckFilePermissionsTaskTest extends TestCase { diff --git a/tests/ConfigurableTaskTraitTest.php b/tests/ConfigurableTaskTraitTest.php index b0a398e..1788e87 100644 --- a/tests/ConfigurableTaskTraitTest.php +++ b/tests/ConfigurableTaskTraitTest.php @@ -19,6 +19,8 @@ /** * Class ConfigurableTaskTraitTest. + * + * Tests covering ConfigurableTaskTrait trait. */ final class ConfigurableTaskTraitTest extends TestCase { diff --git a/tests/ContextRunTraitTest.php b/tests/ContextRunTraitTest.php index 0465378..45cc65b 100644 --- a/tests/ContextRunTraitTest.php +++ b/tests/ContextRunTraitTest.php @@ -16,6 +16,8 @@ /** * Class ContextRunTraitTest. + * + * Tests covering ContextRunTrait trait. */ final class ContextRunTraitTest extends TestCase { diff --git a/tests/Ecs/EcsTaskTest.php b/tests/Ecs/EcsTaskTest.php index f002f16..2625828 100644 --- a/tests/Ecs/EcsTaskTest.php +++ b/tests/Ecs/EcsTaskTest.php @@ -17,6 +17,8 @@ /** * Class EcsTaskTest. + * + * Tests covering Ecs task. */ final class EcsTaskTest extends TestCase { diff --git a/tests/JsonLint/JsonLintTaskTest.php b/tests/JsonLint/JsonLintTaskTest.php index ddb9943..b5c8254 100644 --- a/tests/JsonLint/JsonLintTaskTest.php +++ b/tests/JsonLint/JsonLintTaskTest.php @@ -14,6 +14,8 @@ /** * Class JsonLintTaskTest. + * + * Tests covering JsonLint task. */ final class JsonLintTaskTest extends TestCase { diff --git a/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php b/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php index 9818832..a86cb24 100644 --- a/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php +++ b/tests/PhpCheckSyntax/PhpCheckSyntaxTaskTest.php @@ -16,6 +16,8 @@ /** * Class PhpCompatibilityTaskTest. + * + * Tests covering PhpCheckSyntax task. */ final class PhpCheckSyntaxTaskTest extends TestCase { diff --git a/tests/PhpCompatibility/PhpCompatibilityTaskTest.php b/tests/PhpCompatibility/PhpCompatibilityTaskTest.php index c1496cd..072b730 100644 --- a/tests/PhpCompatibility/PhpCompatibilityTaskTest.php +++ b/tests/PhpCompatibility/PhpCompatibilityTaskTest.php @@ -17,6 +17,8 @@ /** * Class PhpCompatibilityTaskTest. + * + * Tests covering PhpCompatibility task. */ final class PhpCompatibilityTaskTest extends TestCase { diff --git a/tests/Phpcs/PhpcsTaskTest.php b/tests/Phpcs/PhpcsTaskTest.php index dfe2ebc..d58d127 100644 --- a/tests/Phpcs/PhpcsTaskTest.php +++ b/tests/Phpcs/PhpcsTaskTest.php @@ -17,6 +17,8 @@ /** * Class PhpcsTaskTest. + * + * Tests covering Phpcs task. */ final class PhpcsTaskTest extends TestCase { diff --git a/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php b/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php index cf70bb4..6bfa690 100644 --- a/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php +++ b/tests/PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php @@ -17,6 +17,8 @@ /** * Class PhpstanCheckDeprecationTaskTest. + * + * Tests covering PhpstanCheckDeprecation task. */ final class PhpstanCheckDeprecationTaskTest extends TestCase { diff --git a/tests/YamlLint/YamlLintTaskTest.php b/tests/YamlLint/YamlLintTaskTest.php index c537a51..4725f50 100644 --- a/tests/YamlLint/YamlLintTaskTest.php +++ b/tests/YamlLint/YamlLintTaskTest.php @@ -14,6 +14,8 @@ /** * Class YamlLintTaskTest. + * + * Tests covering YamlLint task. */ final class YamlLintTaskTest extends TestCase { From 0ec2b23fdb3f919ad42e074474b1a888bc9df357 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Tue, 8 Dec 2020 19:20:16 +0200 Subject: [PATCH 11/13] Renamed PhpstanCheckDeprecationTask to PhpStanTask --- README.md | 2 +- config/grumphp.yml | 4 ++-- grumphp.yml | 4 ++-- src/Task/PhpStan/PhpStanExtensionLoader.php | 14 ++++++++++++++ .../PhpStanTask.php} | 4 ++-- .../{PhpstanCheckDeprecation => PhpStan}/README.md | 6 +++--- .../PhpstanCheckDeprecationExtensionLoader.php | 14 -------------- src/Task/tasks.yml | 2 +- .../PhpStanTaskTest.php} | 14 +++++++------- 9 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 src/Task/PhpStan/PhpStanExtensionLoader.php rename src/Task/{PhpstanCheckDeprecation/PhpstanCheckDeprecationTask.php => PhpStan/PhpStanTask.php} (88%) rename src/Task/{PhpstanCheckDeprecation => PhpStan}/README.md (83%) delete mode 100644 src/Task/PhpstanCheckDeprecation/PhpstanCheckDeprecationExtensionLoader.php rename tests/{PhpstanCheckDeprecation/PhpstanCheckDeprecationTaskTest.php => PhpStan/PhpStanTaskTest.php} (76%) diff --git a/README.md b/README.md index dfdfd78..ed73faa 100755 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This repository currently has following checks: * Cognitive complexity and other ecs sniffs - [ecs](src/Task/Ecs/README.md) * Yaml syntax - [yaml_lint](src/Task/YamlLint/README.md) * Json syntax - [json_lint](src/Task/JsonLint/README.md) -* Deprecation testing - [phpstan_check_deprecation](src/Task/PhpstanCheckDeprecation/README.md) +* Deprecation testing - [php_stan](src/Task/PhpStan/README.md) ## Pre-requisites diff --git a/config/grumphp.yml b/config/grumphp.yml index 9abf90c..bc940d2 100644 --- a/config/grumphp.yml +++ b/config/grumphp.yml @@ -8,7 +8,7 @@ grumphp: check_file_permissions: ~ php_check_syntax: ~ phpcs: ~ - phpstan_check_deprecation: ~ + php_stan: ~ ecs: ~ yaml_lint: ~ json_lint: ~ @@ -18,6 +18,6 @@ grumphp: - Wunderio\GrumPHP\Task\CheckFilePermissions\CheckFilePermissionsExtensionLoader - Wunderio\GrumPHP\Task\Ecs\EcsExtensionLoader - Wunderio\GrumPHP\Task\Phpcs\PhpcsExtensionLoader - - Wunderio\GrumPHP\Task\PhpstanCheckDeprecation\PhpstanCheckDeprecationExtensionLoader + - Wunderio\GrumPHP\Task\PhpStan\PhpStanExtensionLoader - Wunderio\GrumPHP\Task\YamlLint\YamlLintExtensionLoader - Wunderio\GrumPHP\Task\JsonLint\JsonLintExtensionLoader diff --git a/grumphp.yml b/grumphp.yml index 501e5ec..cba1f1a 100755 --- a/grumphp.yml +++ b/grumphp.yml @@ -8,7 +8,7 @@ grumphp: run_on: ['src', 'tests'] phpcs: run_on: ['src', 'tests'] - phpstan_check_deprecation: + php_stan: run_on: ['src'] configuration: phpstan.neon ecs: @@ -23,6 +23,6 @@ grumphp: - Wunderio\GrumPHP\Task\CheckFilePermissions\CheckFilePermissionsExtensionLoader - Wunderio\GrumPHP\Task\Ecs\EcsExtensionLoader - Wunderio\GrumPHP\Task\Phpcs\PhpcsExtensionLoader - - Wunderio\GrumPHP\Task\PhpstanCheckDeprecation\PhpstanCheckDeprecationExtensionLoader + - Wunderio\GrumPHP\Task\PhpStan\PhpStanExtensionLoader - Wunderio\GrumPHP\Task\YamlLint\YamlLintExtensionLoader - Wunderio\GrumPHP\Task\JsonLint\JsonLintExtensionLoader diff --git a/src/Task/PhpStan/PhpStanExtensionLoader.php b/src/Task/PhpStan/PhpStanExtensionLoader.php new file mode 100644 index 0000000..d5b4532 --- /dev/null +++ b/src/Task/PhpStan/PhpStanExtensionLoader.php @@ -0,0 +1,14 @@ +createMock(ProcessBuilder::class); - $stub = $this->getMockBuilder(PhpstanCheckDeprecationTask::class)->setConstructorArgs([ + $stub = $this->getMockBuilder(PhpStanTask::class)->setConstructorArgs([ $processBuilder, $this->createMock(ProcessFormatterInterface::class), ]) @@ -62,7 +62,7 @@ public function testBuildsProcessArguments(): void { */ protected function getConfigurations(): array { $tasks = Yaml::parseFile(__DIR__ . '/../../src/Task/tasks.yml'); - return $tasks[PhpstanCheckDeprecationTask::class]['options']; + return $tasks[PhpStanTask::class]['options']; } } From d8406326d38a870dd921ca02412ef70bf38a7e46 Mon Sep 17 00:00:00 2001 From: Pasi Kauraniemi Date: Tue, 8 Dec 2020 20:19:39 +0200 Subject: [PATCH 12/13] Use Coding Standard and ECS 8.3. Use ecs.php for ECS. Include CognitiveComplexity checks as PHPStan rules --- composer.json | 10 ++++++++-- config/ecs.php | 24 ++++++++++++++++++++++++ config/ecs.yml | 6 ------ config/phpstan.neon | 13 +++++++++++++ ecs.php | 24 ++++++++++++++++++++++++ ecs.yml | 5 ----- grumphp.yml | 2 +- phpstan.neon | 15 ++++++++++++++- src/Task/tasks.yml | 4 ++-- 9 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 config/ecs.php delete mode 100644 config/ecs.yml create mode 100644 ecs.php delete mode 100644 ecs.yml diff --git a/composer.json b/composer.json index 94ddca4..c48751a 100755 --- a/composer.json +++ b/composer.json @@ -30,14 +30,20 @@ } ], "bin": ["bin/check_perms"], + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/mitrpaka/ecs-drupal" + } + ], "require": { "symfony/polyfill-iconv": "^1", "phpro/grumphp": "^1", "drupal/coder": "^8", "phpcompatibility/php-compatibility": "^9.3", "pheromone/phpcs-security-audit": "^2.0", - "wunderio/ecs-drupal": "^0.2.0", - "symplify/coding-standard": "^6.0", + "wunderio/ecs-drupal": "dev-feature/symplify-ecs-83", + "symplify/coding-standard": "^8.3", "squizlabs/php_codesniffer": "^3.4", "dealerdirect/phpcodesniffer-composer-installer": "*", "mglaman/phpstan-drupal": "^0.12.2", diff --git a/config/ecs.php b/config/ecs.php new file mode 100644 index 0000000..933d13c --- /dev/null +++ b/config/ecs.php @@ -0,0 +1,24 @@ +parameters(); + + // Register services. + $services = $containerConfigurator->services(); + $services->set(DevelAndKintFunctionCallSniff::class); + + // Ignore patterns. + $parameters->set(Option::EXCLUDE_PATHS, [ + '/vendor', + '/node_modules/', + '/core/', + '/libraries/', + ]); + + // Scan file extensions; [default: [php]] + $parameters->set(Option::FILE_EXTENSIONS, ['php', 'inc', 'module', 'install', 'theme']); +}; diff --git a/config/ecs.yml b/config/ecs.yml deleted file mode 100644 index 708d1c8..0000000 --- a/config/ecs.yml +++ /dev/null @@ -1,6 +0,0 @@ -# ecs.yml -services: - Symplify\CodingStandard\Sniffs\CleanCode\CognitiveComplexitySniff: - maxCognitiveComplexity: 16 - Wunderio\CodingStandards\Finder\DrupalFileFinder: ~ - Wunderio\CodingStandards\Sniffs\Debug\KintFunctionCallSniff: ~ diff --git a/config/phpstan.neon b/config/phpstan.neon index 021caa8..b9f4639 100644 --- a/config/phpstan.neon +++ b/config/phpstan.neon @@ -10,3 +10,16 @@ parameters: includes: - vendor/mglaman/phpstan-drupal/extension.neon - vendor/phpstan/phpstan-deprecation-rules/rules.neon + - vendor/symplify/coding-standard/packages/cognitive-complexity/config/cognitive-complexity-services.neon + +services: + - + class: Symplify\CodingStandard\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule + tags: [phpstan.rules.rule] + arguments: + maxMethodCognitiveComplexity: 16 + - + class: Symplify\CodingStandard\CognitiveComplexity\Rules\ClassLikeCognitiveComplexityRule + tags: [phpstan.rules.rule] + arguments: + maxClassCognitiveComplexity: 50 diff --git a/ecs.php b/ecs.php new file mode 100644 index 0000000..933d13c --- /dev/null +++ b/ecs.php @@ -0,0 +1,24 @@ +parameters(); + + // Register services. + $services = $containerConfigurator->services(); + $services->set(DevelAndKintFunctionCallSniff::class); + + // Ignore patterns. + $parameters->set(Option::EXCLUDE_PATHS, [ + '/vendor', + '/node_modules/', + '/core/', + '/libraries/', + ]); + + // Scan file extensions; [default: [php]] + $parameters->set(Option::FILE_EXTENSIONS, ['php', 'inc', 'module', 'install', 'theme']); +}; diff --git a/ecs.yml b/ecs.yml deleted file mode 100644 index 8f58e31..0000000 --- a/ecs.yml +++ /dev/null @@ -1,5 +0,0 @@ -# ecs.yml -services: - Symplify\CodingStandard\Sniffs\CleanCode\CognitiveComplexitySniff: - maxCognitiveComplexity: 8 - Wunderio\CodingStandards\Finder\DrupalFileFinder: ~ diff --git a/grumphp.yml b/grumphp.yml index cba1f1a..4dfe1e1 100755 --- a/grumphp.yml +++ b/grumphp.yml @@ -12,7 +12,7 @@ grumphp: run_on: ['src'] configuration: phpstan.neon ecs: - config: ecs.yml + config: ecs.php yaml_lint: ~ json_lint: ~ phpunit: ~ diff --git a/phpstan.neon b/phpstan.neon index d8ae578..9f085eb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,4 +8,17 @@ parameters: - '#Missing cache backend declaration for performance.#' - '#Plugin manager has cache backend specified but does not declare cache tags.#' includes: - - vendor/phpstan/phpstan-deprecation-rules/rules.neon + - 'vendor/phpstan/phpstan-deprecation-rules/rules.neon' + - 'vendor/symplify/coding-standard/packages/cognitive-complexity/config/cognitive-complexity-services.neon' + +services: + - + class: Symplify\CodingStandard\CognitiveComplexity\Rules\FunctionLikeCognitiveComplexityRule + tags: [phpstan.rules.rule] + arguments: + maxMethodCognitiveComplexity: 16 + - + class: Symplify\CodingStandard\CognitiveComplexity\Rules\ClassLikeCognitiveComplexityRule + tags: [phpstan.rules.rule] + arguments: + maxClassCognitiveComplexity: 50 diff --git a/src/Task/tasks.yml b/src/Task/tasks.yml index c867488..91e966b 100644 --- a/src/Task/tasks.yml +++ b/src/Task/tasks.yml @@ -56,7 +56,7 @@ Wunderio\GrumPHP\Task\Ecs\EcsTask: defaults: false allowed_types: bool config: - defaults: 'vendor/wunderio/code-quality/config/ecs.yml' + defaults: 'vendor/wunderio/code-quality/config/ecs.php' allowed_types: ['string', 'null'] no-progress-bar: defaults: true @@ -185,7 +185,7 @@ Wunderio\GrumPHP\Task\PhpStan\PhpStanTask: defaults: ~ allowed_types: ['string', 'null'] configuration: - defaults: 'phpstan.neon' + defaults: 'vendor/wunderio/code-quality/config/phpstan.neon' allowed_types: ['string', 'null'] memory_limit: defaults: ~ From 9bcce73319454ac2a54d5b33fc86f8a0574e4c4f Mon Sep 17 00:00:00 2001 From: Guntis Jakovins Date: Tue, 8 Dec 2020 21:35:33 +0200 Subject: [PATCH 13/13] Use ecs-drupal 1.0 and above --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c48751a..67f6c92 100755 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "drupal/coder": "^8", "phpcompatibility/php-compatibility": "^9.3", "pheromone/phpcs-security-audit": "^2.0", - "wunderio/ecs-drupal": "dev-feature/symplify-ecs-83", + "wunderio/ecs-drupal": "^1.0", "symplify/coding-standard": "^8.3", "squizlabs/php_codesniffer": "^3.4", "dealerdirect/phpcodesniffer-composer-installer": "*",