rector/create-rector.php.dist

63 lines
1.8 KiB
Plaintext
Raw Normal View History

2020-07-18 20:26:57 +02:00
<?php
declare(strict_types=1);
use PhpParser\Node\Expr\MethodCall;
2020-07-18 20:26:57 +02:00
use Rector\Core\Configuration\Option;
use Rector\RectorGenerator\ValueObject\RecipeOption;
2020-07-18 20:26:57 +02:00
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
// run "bin/rector create" to create a new Rector + tests from this config
2020-07-18 20:26:57 +02:00
return static function (ContainerConfigurator $containerConfigurator): void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::RECTOR_RECIPE, [
RecipeOption::PACKAGE => 'Nette',
RecipeOption::NAME => 'TranslateClassMethodToVariadicsRector',
RecipeOption::NODE_TYPES => [
MethodCall::class,
2020-07-18 20:26:57 +02:00
],
RecipeOption::DESCRIPTION => 'Change translate() method call 2nd arg to variadic',
RecipeOption::CODE_BEFORE => <<<'CODE_SAMPLE'
2020-07-18 20:26:57 +02:00
<?php
use Nette\Localization\ITranslator;
2020-07-18 20:26:57 +02:00
final class SomeClass implements ITranslator
2020-07-18 20:26:57 +02:00
{
public function translate($message, $count = null)
2020-07-18 20:26:57 +02:00
{
return [$message, $count];
2020-07-18 20:26:57 +02:00
}
}
CODE_SAMPLE,
RecipeOption::CODE_AFTER => <<<'CODE_SAMPLE'
2020-07-18 20:26:57 +02:00
<?php
use Nette\Localization\ITranslator;
2020-07-18 20:26:57 +02:00
final class SomeClass implements ITranslator
2020-07-18 20:26:57 +02:00
{
public function translate($message, ... $parameters)
{
$count = $parameters[0] ?? null;
return [$message, $count];
}
2020-07-18 20:26:57 +02:00
}
CODE_SAMPLE,
// e.g. link to RFC or headline in upgrade guide, 1 or more in the list
RecipeOption::SOURCE => [
'https://github.com/nette/utils/pull/178'
2020-07-18 20:26:57 +02:00
],
// e.g. symfony30, target set to add this Rule to; keep null if part of core
RecipeOption::SET => null,
// OPTIONAL: only when configured
RecipeOption::RULE_CONFIGURATION => null,
// OPTIONAL: extra file
RecipeOption::EXTRA_FILE_NAME => null,
RecipeOption::EXTRA_FILE_CONTENT => null,
2020-07-18 20:26:57 +02:00
]);
};