mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
use short config in code samples + update Rector overview
This commit is contained in:
parent
9eb3057bc0
commit
0abecd8087
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ final class JmsInjectAnnotationRector extends AbstractRector
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Changes properties with @JMS\DiExtraBundle\Annotation\Inject to constructor injection',
|
||||
'Changes properties with `@JMS\DiExtraBundle\Annotation\Inject` to constructor injection',
|
||||
[
|
||||
new CodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
|
@ -19,7 +19,7 @@ final class ExceptionHandlerTypehintRector extends AbstractRector
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Changes property @var annotations from annotation to type.',
|
||||
'Changes property `@var` annotations from annotation to type.',
|
||||
[
|
||||
new CodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
|
@ -62,7 +62,7 @@ final class TypedPropertyRector extends AbstractRector
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Changes property @var annotations from annotation to type.',
|
||||
'Changes property `@var` annotations from annotation to type.',
|
||||
[
|
||||
new CodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
|
@ -26,9 +26,9 @@ final class SensitiveHereNowDocRector extends AbstractRector
|
||||
return new RectorDefinition('Changes heredoc/nowdoc that contains closing word to safe wrapper name', [
|
||||
new CodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
$value = <<<A
|
||||
A
|
||||
$value = <<<A
|
||||
A
|
||||
A
|
||||
CODE_SAMPLE
|
||||
,
|
||||
<<<'CODE_SAMPLE'
|
||||
|
@ -53,7 +53,7 @@ final class TemplateAnnotationRector extends AbstractRector
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Turns @Template annotation to explicit method call in Controller of FrameworkExtraBundle in Symfony',
|
||||
'Turns `@Template` annotation to explicit method call in Controller of FrameworkExtraBundle in Symfony',
|
||||
[
|
||||
new CodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
|
@ -3,12 +3,14 @@
|
||||
namespace Rector\Console;
|
||||
|
||||
use Jean85\PrettyVersions;
|
||||
use Rector\Console\Command\GenerateRectorOverviewCommand;
|
||||
use Symfony\Component\Console\Application as SymfonyApplication;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputDefinition;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use function Safe\getcwd;
|
||||
use function Safe\realpath;
|
||||
|
||||
@ -33,6 +35,11 @@ final class Application extends SymfonyApplication
|
||||
{
|
||||
$shouldFollowByNewline = false;
|
||||
|
||||
// skip in this case, since generate content must be clear from meta-info
|
||||
if ($input->getFirstArgument() === CommandNaming::classToName(GenerateRectorOverviewCommand::class)) {
|
||||
return parent::doRun($input, $output);
|
||||
}
|
||||
|
||||
if ($this->isVersionPrintedElsewhere($input) === false) {
|
||||
// always print name version to more debug info
|
||||
$output->writeln($this->getLongVersion());
|
||||
|
@ -252,7 +252,9 @@ final class GenerateRectorOverviewCommand extends Command
|
||||
$this->printCodeWrapped($diff, 'diff');
|
||||
}
|
||||
|
||||
$this->symfonyStyle->newLine(1);
|
||||
$this->symfonyStyle->newLine();
|
||||
$this->symfonyStyle->writeln('<br>');
|
||||
$this->symfonyStyle->newLine();
|
||||
}
|
||||
|
||||
private function getRectorClassWithoutNamespace(RectorInterface $rector): string
|
||||
|
@ -68,10 +68,8 @@ class SomeTest extends PHPUnit\Framework\TestCase
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$classToAnnotationMap' => [
|
||||
'PHPUnit\Framework\TestCase' => [
|
||||
'test' => 'scenario',
|
||||
],
|
||||
'PHPUnit\Framework\TestCase' => [
|
||||
'test' => 'scenario',
|
||||
],
|
||||
]
|
||||
),
|
||||
|
@ -39,7 +39,7 @@ final class AnnotatedPropertyInjectToConstructorInjectionRector extends Abstract
|
||||
public function getDefinition(): RectorDefinition
|
||||
{
|
||||
return new RectorDefinition(
|
||||
'Turns non-private properties with @annotation to private properties and constructor injection',
|
||||
'Turns non-private properties with `@annotation` to private properties and constructor injection',
|
||||
[
|
||||
new ConfiguredCodeSample(
|
||||
<<<'CODE_SAMPLE'
|
||||
|
@ -51,14 +51,12 @@ $someObject->someMethod(false);'
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$argumentChangesByMethodAndType' => [
|
||||
'SomeExampleClass' => [
|
||||
'someMethod' => [
|
||||
0 => [
|
||||
[
|
||||
'before' => 'SomeClass::OLD_CONSTANT',
|
||||
'after' => 'false',
|
||||
],
|
||||
'SomeExampleClass' => [
|
||||
'someMethod' => [
|
||||
0 => [
|
||||
[
|
||||
'before' => 'SomeClass::OLD_CONSTANT',
|
||||
'after' => 'false',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -51,9 +51,7 @@ function (SomeNewClass $someOldClass): SomeNewClass
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$oldToNewClasses' => [
|
||||
'SomeOldClass' => 'SomeNewClass',
|
||||
],
|
||||
'SomeOldClass' => 'SomeNewClass',
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -56,9 +56,7 @@ class SomeClass
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$parentClassToTraits' => [
|
||||
'Nette\Object' => ['Nette\SmartObject'],
|
||||
],
|
||||
'Nette\Object' => ['Nette\SmartObject'],
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -35,10 +35,8 @@ final class ClassConstantReplacerRector extends AbstractRector
|
||||
'$value = SomeClass::OLD_CONSTANT;',
|
||||
'$value = SomeClass::NEW_CONSTANT;',
|
||||
[
|
||||
'$oldToNewConstantsByClass' => [
|
||||
'SomeClass' => [
|
||||
'OLD_CONSTANT' => 'NEW_CONSTANT',
|
||||
],
|
||||
'SomeClass' => [
|
||||
'OLD_CONSTANT' => 'NEW_CONSTANT',
|
||||
],
|
||||
]
|
||||
),
|
||||
|
@ -31,9 +31,7 @@ final class FunctionReplaceRector extends AbstractRector
|
||||
'view("...", []);',
|
||||
'Laravel\Templating\render("...", []);',
|
||||
[
|
||||
'$functionToStaticCall' => [
|
||||
'view' => 'Laravel\Templating\render',
|
||||
],
|
||||
'view' => 'Laravel\Templating\render',
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -32,9 +32,7 @@ final class FunctionToMethodCallRector extends AbstractRector
|
||||
'view("...", []);',
|
||||
'$this->render("...", []);',
|
||||
[
|
||||
'$functionToMethodCall' => [
|
||||
'view' => ['this', 'render'],
|
||||
],
|
||||
'view' => ['this', 'render'],
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -33,9 +33,7 @@ final class FunctionToStaticCallRector extends AbstractRector
|
||||
'view("...", []);',
|
||||
'SomeClass::render("...", []);',
|
||||
[
|
||||
'$functionToStaticCall' => [
|
||||
'view' => ['SomeStaticClass', 'render'],
|
||||
],
|
||||
'view' => ['SomeStaticClass', 'render'],
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -47,9 +47,7 @@ class SomeClass implements SomeInterface
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$oldToNewInterfaces' => [
|
||||
'SomeOldInterface' => 'SomeInterface',
|
||||
],
|
||||
'SomeOldInterface' => 'SomeInterface',
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -50,10 +50,8 @@ $container->setService("someService", $someService);
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$typeToMethodCalls' => [
|
||||
'SomeContainer' => [
|
||||
'set' => 'addService',
|
||||
],
|
||||
'SomeContainer' => [
|
||||
'set' => 'addService',
|
||||
],
|
||||
]
|
||||
),
|
||||
|
@ -44,9 +44,7 @@ $result = $someValue->getPath();
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$methodNamesByType' => [
|
||||
'SomeObject' => 'getPath',
|
||||
],
|
||||
'SomeObject' => 'getPath',
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -42,10 +42,8 @@ $container->hasService("someKey");
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$typeToMethodCalls' => [
|
||||
'SomeContainer' => [
|
||||
'isset' => 'hasService',
|
||||
],
|
||||
'SomeContainer' => [
|
||||
'isset' => 'hasService',
|
||||
],
|
||||
]
|
||||
),
|
||||
@ -61,12 +59,8 @@ $container->removeService("someKey");
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
[
|
||||
'$typeToMethodCalls' => [
|
||||
'SomeContainer' => [
|
||||
'unset' => 'removeService',
|
||||
],
|
||||
],
|
||||
'SomeContainer' => [
|
||||
'unset' => 'removeService',
|
||||
],
|
||||
]
|
||||
),
|
||||
|
@ -39,9 +39,7 @@ $someClass->someFunction();
|
||||
$someClass->otherFunction();
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$classesToDefluent' => ['SomeExampleClass'],
|
||||
]
|
||||
[['SomeExampleClass']]
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
@ -47,9 +47,7 @@ $someObject->someFunction()
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$fluentMethodsByType' => [
|
||||
'SomeClass' => ['someFunction', 'otherFunction'],
|
||||
],
|
||||
'SomeClass' => ['someFunction', 'otherFunction'],
|
||||
]
|
||||
),
|
||||
]);
|
||||
|
@ -65,9 +65,7 @@ class SomeClass
|
||||
}
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$classesToDefluent' => ['SomeExampleClass'],
|
||||
]
|
||||
[['SomeExampleClass']]
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
@ -43,10 +43,8 @@ $someObject->newMethod();
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$perClassOldToNewMethods' => [
|
||||
'SomeExampleClass' => [
|
||||
'oldMethod' => 'newMethod',
|
||||
],
|
||||
'SomeExampleClass' => [
|
||||
'oldMethod' => 'newMethod',
|
||||
],
|
||||
]
|
||||
),
|
||||
|
@ -32,10 +32,8 @@ final class StaticMethodNameReplacerRector extends AbstractRector
|
||||
'SomeClass::oldStaticMethod();',
|
||||
'AnotherExampleClass::newStaticMethod();',
|
||||
[
|
||||
'$oldToNewMethodByClasses' => [
|
||||
'SomeClass' => [
|
||||
'oldMethod' => ['AnotherExampleClass', 'newStaticMethod'],
|
||||
],
|
||||
'SomeClass' => [
|
||||
'oldMethod' => ['AnotherExampleClass', 'newStaticMethod'],
|
||||
],
|
||||
]
|
||||
),
|
||||
|
@ -68,11 +68,9 @@ class SomeClass implements SomeInterface
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$typehintForArgumentByMethodAndClass' => [
|
||||
'SomeInterface' => [
|
||||
'read' => [
|
||||
'$content' => 'string',
|
||||
],
|
||||
'SomeInterface' => [
|
||||
'read' => [
|
||||
'$content' => 'string',
|
||||
],
|
||||
],
|
||||
]
|
||||
|
@ -8,7 +8,6 @@ use Rector\PhpParser\Node\Maintainer\VisibilityMaintainer;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Rector\Tests\Rector\Visibility\ChangeConstantVisibilityRector\Source\ParentObject;
|
||||
|
||||
final class ChangeConstantVisibilityRector extends AbstractRector
|
||||
{
|
||||
@ -61,10 +60,8 @@ class MyClass extends FrameworkClass
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
ParentObject::class => [
|
||||
'$constantToVisibilityByClass' => [
|
||||
'SOME_CONSTANT' => 'protected',
|
||||
],
|
||||
'ParentObject' => [
|
||||
'SOME_CONSTANT' => 'protected',
|
||||
],
|
||||
]
|
||||
)]
|
||||
|
@ -69,10 +69,8 @@ class MyClass extends FrameworkClass
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$methodToVisibilityByClass' => [
|
||||
'FrameworkClass' => [
|
||||
'someMethod' => 'protected',
|
||||
],
|
||||
'FrameworkClass' => [
|
||||
'someMethod' => 'protected',
|
||||
],
|
||||
]
|
||||
)]
|
||||
|
@ -61,10 +61,8 @@ class MyClass extends FrameworkClass
|
||||
CODE_SAMPLE
|
||||
,
|
||||
[
|
||||
'$propertyToVisibilityByClass' => [
|
||||
'FrameworkClass' => [
|
||||
'someProperty' => 'protected',
|
||||
],
|
||||
'FrameworkClass' => [
|
||||
'someProperty' => 'protected',
|
||||
],
|
||||
]
|
||||
)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user