2020-07-18 20:26:57 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
use PhpParser\Node\Stmt\ClassMethod;
|
|
|
|
use Rector\Core\Configuration\Option;
|
2020-07-20 14:18:15 +02:00
|
|
|
use Rector\Set\ValueObject\Set;
|
2020-07-18 20:26:57 +02:00
|
|
|
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
|
|
|
|
|
|
|
return static function (ContainerConfigurator $containerConfigurator): void {
|
|
|
|
$parameters = $containerConfigurator->parameters();
|
|
|
|
|
|
|
|
$parameters->set(Option::RECTOR_RECIPE, [
|
|
|
|
# run "bin/rector create" to create a new Rector + tests from this config
|
|
|
|
'package' => 'Symfony',
|
|
|
|
'name' => 'RemoveDefaultGetBlockPrefixRector',
|
|
|
|
'node_types' => [
|
|
|
|
ClassMethod::class,
|
|
|
|
],
|
|
|
|
'description' => 'Rename `getBlockPrefix()` if it returns the default value - class to underscore, e.g. UserFormType = user_form',
|
|
|
|
'code_before' => <<<'CODE_SAMPLE'
|
|
|
|
<?php
|
|
|
|
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
|
|
|
|
|
|
class TaskType extends AbstractType
|
|
|
|
{
|
|
|
|
public function getBlockPrefix()
|
|
|
|
{
|
|
|
|
return 'task';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CODE_SAMPLE,
|
|
|
|
'code_after' => <<<'CODE_SAMPLE'
|
|
|
|
<?php
|
|
|
|
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
|
|
|
|
|
|
class TaskType extends AbstractType
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CODE_SAMPLE,
|
|
|
|
'source' => [
|
|
|
|
# e.g. link to RFC or headline in upgrade guide, 1 or more in the list
|
|
|
|
'https://github.com/symfony/symfony/blob/3.4/UPGRADE-3.0.md',
|
|
|
|
],
|
|
|
|
# e.g. symfony30, target config to append this rector to
|
2020-07-20 00:52:12 +02:00
|
|
|
'set' => Set::SYMFONY_30,
|
2020-07-18 20:26:57 +02:00
|
|
|
]);
|
|
|
|
};
|