This PR makes sure that the GrumPHP TaskInterface only has a dependency to the GrumPHP\\ namespace.
Symfony OptionsResolver will not be a part of the task interface anymore.
New task interface:
namespace GrumPHP\Task;
use GrumPHP\Runner\TaskResultInterface;
use GrumPHP\Task\Config\ConfigOptionsResolver;
use GrumPHP\Task\Config\TaskConfigInterface;
use GrumPHP\Task\Context\ContextInterface;
interface TaskInterface
{
public static function getConfigurableOptions(): ConfigOptionsResolver;
public function canRunInContext(ContextInterface $context): bool;
public function run(ContextInterface $context): TaskResultInterface;
public function getConfig(): TaskConfigInterface;
public function withConfig(TaskConfigInterface $config): TaskInterface;
}
This makes it possible for extensions to provide tasks that are compatible with the grumphp-shim release.
In order to make the task compatible, you'll need to wrap the symfony options-resolver with GrumPHP's own options-resolver:
public static function getConfigurableOptions(): ConfigOptionsResolver
{
$resolver = new OptionsResolver();
// ..... your config
return ConfigOptionsResolver::fromClosure(
static fn (array $options): array => $resolver->resolve($options)
);
}
❗ In extensions, you do not want to use \GrumPHP\Task\Config\ConfigOptionsResolver::fromOptionsResolver() - since Symfony's options resolver will be scoped (prefixed) in grumphp-shim's phar distrubition.
Fixes https://github.com/phpro/grumphp-shim/issues/10
This PR makes sure that the GrumPHP
TaskInterface
only has a dependency to theGrumPHP\\
namespace. Symfony OptionsResolver will not be a part of the task interface anymore.New task interface:
This makes it possible for extensions to provide tasks that are compatible with the
grumphp-shim
release. In order to make the task compatible, you'll need to wrap the symfony options-resolver with GrumPHP's own options-resolver:❗ In extensions, you do not want to use
\GrumPHP\Task\Config\ConfigOptionsResolver::fromOptionsResolver()
- since Symfony's options resolver will be scoped (prefixed) ingrumphp-shim
's phar distrubition.