Skip to content

Commit

Permalink
Remove v1 deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed May 25, 2023
1 parent cd90aef commit fd4c117
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 102 deletions.
27 changes: 0 additions & 27 deletions spec/Exception/DeprecatedExceptionSpec.php

This file was deleted.

7 changes: 0 additions & 7 deletions spec/Exception/TaskConfigResolverExceptionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,4 @@ public function it_handles_unknown_class(): void
$this->beConstructedThrough('unknownClass', [$class = 'SomeClass']);
$this->getMessage()->shouldContain($class);
}

public function it_handles_deprecated_task(): void
{
$this->beConstructedThrough('deprectatedTask', [$task = 'taskName']);
$this->getMessage()->shouldContain($task);
$this->getMessage()->shouldContain('https://github.com/phpro/grumphp/blob/master/doc/tasks.md#creating-a-custom-task');
}
}
23 changes: 2 additions & 21 deletions src/Configuration/Compiler/TaskCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\OptionsResolver\Exception\MissingOptionsException;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class TaskCompilerPass implements CompilerPassInterface
Expand Down Expand Up @@ -92,29 +90,12 @@ private function getTaskTag(array $tag): array
if (null === $taskTagResolver) {
$taskTagResolver = new OptionsResolver();

// Instead of required task param : use this to enable the fallback for the deprecated tasks.
$taskTagResolver->setDefined(['task', 'aliasFor', 'priority']);
$taskTagResolver->setRequired(['task']);
$taskTagResolver->setDefined(['aliasFor', 'priority']);
$taskTagResolver->setAllowedTypes('task', ['string']);
$taskTagResolver->setAllowedTypes('aliasFor', ['string', 'null']);
$taskTagResolver->setAllowedTypes('priority', ['int']);
$taskTagResolver->setDefault('task', '');
$taskTagResolver->setDefault('priority', 0);
$taskTagResolver->setNormalizer('task', static function (Options $options, ?string $value) {
if (!$value && !$options->offsetExists('config')) {
throw new MissingOptionsException('The required option "task" is missing.');
}

return $value;
});

// Clean fallback for installation with old tasks.
$taskTagResolver->setDefined('config');
$taskTagResolver->setNormalizer(
'config',
static function (Options $options, string $value) {
throw TaskConfigResolverException::deprectatedTask($value);
}
);
}

return $taskTagResolver->resolve($tag);
Expand Down
6 changes: 0 additions & 6 deletions src/Configuration/GrumPHPExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace GrumPHP\Configuration;

use GrumPHP\Exception\DeprecatedException;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
Expand Down Expand Up @@ -35,11 +34,6 @@ public function getAlias(): string
private function loadInternal(array $config, ContainerBuilder $container): void
{
foreach ($config as $key => $value) {
// We require using grumphp instead of parameters at this point:
if ($container->hasParameter($key)) {
throw DeprecatedException::directParameterConfiguration($key);
}

$container->setParameter($key, $value);
}
}
Expand Down
17 changes: 0 additions & 17 deletions src/Exception/DeprecatedException.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/Exception/TaskConfigResolverException.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,4 @@ public static function unknownClass(string $class): self
)
);
}

public static function deprectatedTask(string $taskName): self
{
return new self(
'Your configuration contains an old task implementation for "'.$taskName.'".' . PHP_EOL
. 'This task cannot be used in current setup.' . PHP_EOL
. 'Please upgrade your extension(s) or fall back to a previous version of GrumPHP.' . PHP_EOL
. 'More information about the new task system: '. PHP_EOL
. 'https://github.com/phpro/grumphp/blob/master/doc/tasks.md#creating-a-custom-task' . PHP_EOL . PHP_EOL
);
}
}
13 changes: 0 additions & 13 deletions src/Task/ESLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
$resolver->addAllowedTypes('no_eslintrc', ['bool']);
$resolver->addAllowedTypes('quiet', ['bool']);

$resolver->setDeprecated(
'whitelist_patterns',
'phpro/grumphp',
'1.14',
function (Options $options, mixed $value): string {
if (null === $value) {
return 'Parsing "null" to option "whitelist_patterns" is deprecated, pass an array instead.';
}

return '';
}
);

return ConfigOptionsResolver::fromOptionsResolver($resolver);
}

Expand Down

0 comments on commit fd4c117

Please sign in to comment.