Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove v1 deprecations #1092

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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