regenerate overview

This commit is contained in:
Tomas Votruba 2018-05-04 15:12:53 +01:00
parent 01ae547422
commit 7787cf5dc2

View File

@ -20,10 +20,8 @@ Turns parent EntityRepository class to constructor dependency
```diff
namespace App\Repository;
+use App\Entity\Post;
use Doctrine\ORM\EntityRepository;
-final class PostRepository extends EntityRepository
+final class PostRepository
{
@ -90,7 +88,6 @@ Turns method data providers in PHPUnit from arrays to yield
$someObject = new SomeClass;
-$someObject->oldMethod();
+$someObject->newMethod();
-SomeClass::oldStaticMethod();
+SomeClass::newStaticMethod();
```
@ -136,14 +133,14 @@ class SomeClass implements SomeInterface
}
```
## Rector\Rector\Dynamic\ArgumentRector
## Rector\Rector\Dynamic\ArgumentRemoverRector
[Dynamic] Adds, removes or replaces defined arguments in defined methods and their calls.
[Dynamic] Removes defined arguments in defined methods and their calls.
```diff
$containerBuilder = new Symfony\Component\DependencyInjection\ContainerBuilder;
-$containerBuilder->compile();
+$containerBuilder->compile(true);
-$containerBuilder->compile(true);
+$containerBuilder->compile();
```
## Rector\Rector\Dynamic\FunctionToMethodCallRector
@ -162,8 +159,7 @@ Turns properties with @inject to private properties and constructor injection
```diff
/**
* @var SomeService
- * @inject
*/
- * @inject */
-public $someService;
+private $someService;
+
@ -196,8 +192,7 @@ Turns setInject() to tag in Nette\DI\CompilerExtension
Checks all Nette\Object instances and turns parent class to trait
```diff
-class SomeClass extends \Nette\Object { }
+class SomeClass { use Nette\SmartObject; }
-class SomeClass extends \Nette\Object { }+class SomeClass { use Nette\SmartObject; }
```
## Rector\Rector\Contrib\Nette\Utils\MagicMethodRector
@ -243,7 +238,6 @@ Turns expand() to parameters value in Nette\DI\CompilerExtension
```diff
-$builder->expand("argument");
+$builder->parameters["argument"];
-$builder->expand("%argument%");
+$builder->parameters["argument"];
```
@ -291,7 +285,6 @@ Turns magic callback assign to callback assign on Nette Form events.
```diff
-$someService = $container->someService;
+$container->getService("someService");
-$container->someService = $someService;
+$container->setService("someService", $someService);
```
@ -303,7 +296,6 @@ Turns magic callback assign to callback assign on Nette Form events.
```diff
-isset($container["someKey"]);
+$container->hasService("someKey");
-unset($container["someKey"])
+$container->removeService("someKey");
```
@ -321,19 +313,18 @@ Turns node string names to Identifier object in php-parser
## Rector\Rector\Contrib\PhpParser\ParamAndStaticVarNameRector
Turns old string var to var->name sub-variable in Node of PHP-Parser
Turns old string `var` to `var->name` sub-variable in Node of PHP-Parser
```diff
-$paramNode->name;
+$paramNode->var->name;
-$staticVarNode->name;
+$staticVarNode->var->name;
```
## Rector\Rector\Contrib\PhpParser\CatchAndClosureUseNameRector
Turns $catchNode->var to its new new ->name property in php-parser
Turns `$catchNode->var` to its new `name` property in php-parser
```diff
-$catchNode->var;
@ -363,12 +354,11 @@ public function leaveNode()
## Rector\Rector\Contrib\PhpParser\UseWithAliasRector
Turns use property to method and $node->alias to last name in UseAlias Node of PHP-Parser
Turns use property to method and `$node->alias` to last name in UseAlias Node of PHP-Parser
```diff
-$node->alias;
+$node->getAlias();
-$node->name->getLast();
+$node->alias
```
@ -398,7 +388,6 @@ Turns not-operator comparisons to their method name alternatives in PHPUnit Test
```diff
-$this->assertTrue(!$foo, "message");
+$this->assertFalse($foo, "message");
-$this->assertFalse(!$foo, "message");
+$this->assertTrue($foo, "message");
```
@ -410,7 +399,6 @@ Turns comparison operations to their method name alternatives in PHPUnit TestCas
```diff
-$this->assertTrue($foo === $bar, "message");
+$this->assertSame($bar, $foo, "message");
-$this->assertFalse($foo >= $bar, "message");
+$this->assertLessThanOrEqual($bar, $foo, "message");
```
@ -431,7 +419,6 @@ Turns same bool and null comparisons to their method name alternatives in PHPUni
```diff
-$this->assertSame(null, $anything);
+$this->assertNull($anything);
-$this->assertNotSame(false, $anything);
+$this->assertNotFalse($anything);
```
@ -443,7 +430,6 @@ Turns `strpos`/`stripos` comparisons to their method name alternatives in PHPUni
```diff
-$this->assertFalse(strpos($anything, "foo"), "message");
+$this->assertNotContains("foo", $anything, "message");
-$this->assertNotFalse(stripos($anything, "foo"), "message");
+$this->assertContains("foo", $anything, "message");
```
@ -455,7 +441,6 @@ Turns true/false with internal type comparisons to their method name alternative
```diff
-$this->assertTrue(is_{internal_type}($anything), "message");
+$this->assertInternalType({internal_type}, $anything, "message");
-$this->assertFalse(is_{internal_type}($anything), "message");
+$this->assertNotInternalType({internal_type}, $anything, "message");
```
@ -467,16 +452,12 @@ Turns vague php-only method in PHPUnit TestCase to more specific
```diff
-$this->assertSame(10, count($anything), "message");
+$this->assertCount(10, $anything, "message");
-$this->assertSame($value, {function}($anything), "message");
+$this->assert{function}($value, $anything, "message\");
-$this->assertEquals($value, {function}($anything), "message");
+$this->assert{function}($value, $anything, "message\");
-$this->assertNotSame($value, {function}($anything), "message");
+$this->assertNot{function}($value, $anything, "message")
-$this->assertNotEquals($value, {function}($anything), "message");
+$this->assertNot{function}($value, $anything, "message")
```
@ -488,7 +469,6 @@ Turns isset comparisons to their method name alternatives in PHPUnit TestCase
```diff
-$this->assertTrue(isset($anything->foo));
+$this->assertFalse(isset($anything["foo"]), "message");
-$this->assertObjectHasAttribute("foo", $anything);
+$this->assertArrayNotHasKey("foo", $anything, "message");
```
@ -500,7 +480,6 @@ Turns instanceof comparisons to their method name alternatives in PHPUnit TestCa
```diff
-$this->assertTrue($foo instanceof Foo, "message");
+$this->assertFalse($foo instanceof Foo, "message");
-$this->assertInstanceOf("Foo", $foo, "message");
+$this->assertNotInstanceOf("Foo", $foo, "message");
```
@ -512,7 +491,6 @@ Turns `property_exists` comparisons to their method name alternatives in PHPUnit
```diff
-$this->assertTrue(property_exists(new Class, "property"), "message");
+$this->assertClassHasAttribute("property", "Class", "message");
-$this->assertFalse(property_exists(new Class, "property"), "message");
+$this->assertClassNotHasAttribute("property", "Class", "message");
```
@ -524,14 +502,13 @@ Turns `preg_match` comparisons to their method name alternatives in PHPUnit Test
```diff
-$this->assertSame(1, preg_match("/^Message for ".*"\.$/", $string), $message);
+$this->assertRegExp("/^Message for ".*"\.$/", $string, $message);
-$this->assertEquals(false, preg_match("/^Message for ".*"\.$/", $string), $message);
+$this->assertNotRegExp("/^Message for ".*"\.$/", $string, $message);
```
## Rector\Rector\Contrib\PHPUnit\ExceptionAnnotationRector
Takes `setExpectedException` 2nd and next arguments to own methods in PHPUnit.
Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.
```diff
-/**
@ -553,7 +530,6 @@ Turns getMock*() methods to createMock()
```diff
-$this->getMock("Class")
+$this->createMock("Class")
-$this->getMockWithoutInvokingTheOriginalConstructor("Class")
+$this->createMock("Class"
```
@ -569,7 +545,7 @@ Turns getMock*() methods to createMock()
## Rector\Rector\Contrib\PHPUnit\DelegateExceptionArgumentsRector
Takes `setExpectedException` 2nd and next arguments to own methods in PHPUnit.
Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.
```diff
-$this->setExpectedException(Exception::class, "Message", "CODE");
@ -611,7 +587,7 @@ Turns @Template annotation to explicit method call in Controller of FrameworkExt
## Rector\Rector\Contrib\Sylius\Review\ReplaceCreateMethodWithoutReviewerRector
Turns `createForSubjectWithReviewer` with null review to standalone method in Sylius
Turns `createForSubjectWithReviewer()` with null review to standalone method in Sylius
```diff
-$this->createForSubjectWithReviewer($subject, null)
@ -632,7 +608,7 @@ class SomeClass
## Rector\Rector\Contrib\Symfony\FrameworkBundle\ContainerGetToConstructorInjectionRector
Turns fetching of dependencies via $container->get() in ContainerAware to constructor injection in Command and Controller in Symfony
Turns fetching of dependencies via `$container->get()` in ContainerAware to constructor injection in Command and Controller in Symfony
```diff
-class MyCommand extends ContainerAwareCommand
@ -656,7 +632,7 @@ Turns fetching of dependencies via $container->get() in ContainerAware to constr
## Rector\Rector\Contrib\Symfony\FrameworkBundle\GetParameterToConstructorInjectionRector
Turns fetching of parameters via getParmaeter() in ContainerAware to constructor injection in Command and Controller in Symfony
Turns fetching of parameters via `getParameter()` in ContainerAware to constructor injection in Command and Controller in Symfony
```diff
-class MyCommand extends ContainerAwareCommand
@ -679,7 +655,7 @@ Turns fetching of parameters via getParmaeter() in ContainerAware to constructor
## Rector\Rector\Contrib\Symfony\FrameworkBundle\GetToConstructorInjectionRector
Turns fetching of dependencies via $this->get() to constructor injection in Command and Controller in Symfony
Turns fetching of dependencies via `$this->get()` to constructor injection in Command and Controller in Symfony
```diff
-class MyCommand extends ContainerAwareCommand
@ -719,7 +695,7 @@ Turns long flash adding to short helper method in Controller in Symfony
## Rector\Rector\Contrib\Symfony\HttpKernel\GetRequestRector
Turns fetching of dependencies via $this->get() to constructor injection in Command and Controller in Symfony
Turns fetching of dependencies via `$this->get()` to constructor injection in Command and Controller in Symfony
```diff
+use Symfony\Component\HttpFoundation\Request;
@ -737,12 +713,11 @@ Turns fetching of dependencies via $this->get() to constructor injection in Comm
## Rector\Rector\Contrib\Symfony\Form\FormTypeGetParentRector
Turns string Form Type references to their CONSTANT alternatives in getParent() and getExtendedType() methods in Form in Symfony
Turns string Form Type references to their CONSTANT alternatives in `getParent()` and `getExtendedType()` methods in Form in Symfony
```diff
-function getParent() { return "collection"; }
+function getParent() { return CollectionType::class; }
-function getExtendedType() { return "collection"; }
+function getExtendedType() { return CollectionType::class; }
```
@ -756,6 +731,16 @@ Turns old option names to new ones in FormTypes in Form in Symfony
+$builder->add("...", ["scale" => "...", "inherit_data" => "..."];
```
## Rector\Rector\Dynamic\ArgumentAdderRector
[Dynamic] Adds or replaces defined arguments in defined methods and their calls.
```diff
$containerBuilder = new Symfony\Component\DependencyInjection\ContainerBuilder;
-$containerBuilder->compile();
+$containerBuilder->compile(true);
```
## Rector\Rector\Contrib\Symfony\Console\ConsoleExceptionToErrorEventConstantRector
Turns old event name with EXCEPTION to ERROR constant in Console in Symfony
@ -763,14 +748,13 @@ Turns old event name with EXCEPTION to ERROR constant in Console in Symfony
```diff
-"console.exception"
+Symfony\Component\Console\ConsoleEvents::ERROR
-Symfony\Component\Console\ConsoleEvents::EXCEPTION
+Symfony\Component\Console\ConsoleEvents::ERROR
```
## Rector\Rector\Contrib\Symfony\Validator\ConstraintUrlOptionRector
Turns true value to Url::CHECK_DNS_TYPE_ANY in Validator in Symfony.
Turns true value to `Url::CHECK_DNS_TYPE_ANY` in Validator in Symfony.
```diff
-$constraint = new Url(["checkDNS" => true]);
@ -779,7 +763,7 @@ Turns true value to Url::CHECK_DNS_TYPE_ANY in Validator in Symfony.
## Rector\Rector\Contrib\Symfony\Form\FormIsValidRector
Adds $form->isSubmitted() validatoin to all $form->isValid() calls in Form in Symfony
Adds `$form->isSubmitted()` validatoin to all `$form->isValid()` calls in Form in Symfony
```diff
-if ($form->isValid()) { ... };
@ -797,12 +781,11 @@ Turns string Form Type references to their CONSTANT alternatives in FormTypes in
## Rector\Rector\Contrib\Symfony\VarDumper\VarDumperTestTraitMethodArgsRector
Adds new $format argument in VarDumperTestTrait->assertDumpEquals() in in Validator in Symfony.
Adds new `$format` argument in `VarDumperTestTrait->assertDumpEquals()` in Validator in Symfony.
```diff
-VarDumperTestTrait->assertDumpEquals($dump, $data, $mesage = "");
+VarDumperTestTrait->assertDumpEquals($dump, $data, $context = null, $mesage = "");
-VarDumperTestTrait->assertDumpMatchesFormat($dump, $format, $mesage = "");
+VarDumperTestTrait->assertDumpMatchesFormat($dump, $format, $context = null, $mesage = "");
```
@ -818,7 +801,7 @@ Turns old default value to parameter in ContinerBuilder->build() method in DI in
## Rector\Rector\Contrib\Symfony\Process\ProcessBuilderInstanceRector
Turns ProcessBuilder::instance() to new ProcessBuilder in Process in Symfony. Part of multi-step Rector.
Turns `ProcessBuilder::instance()` to new ProcessBuilder in Process in Symfony. Part of multi-step Rector.
```diff
-$processBuilder = Symfony\Component\Process\ProcessBuilder::instance($args);
@ -827,7 +810,7 @@ Turns ProcessBuilder::instance() to new ProcessBuilder in Process in Symfony. Pa
## Rector\Rector\Contrib\Symfony\Process\ProcessBuilderGetProcessRector
Removes $processBuilder->getProcess() calls to $processBuilder in Process in Symfony, because ProcessBuilder was removed. This is part of multi-step Rector and has very narrow focus.
Removes `$processBuilder->getProcess()` calls to $processBuilder in Process in Symfony, because ProcessBuilder was removed. This is part of multi-step Rector and has very narrow focus.
```diff
$processBuilder = new Symfony\Component\Process\ProcessBuilder;