mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 08:25:02 +02:00
regenerated docs/AllRectorsOverview.md
This commit is contained in:
parent
fb3c55ecfa
commit
c62a23dd8b
@ -21,10 +21,10 @@ 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
|
||||
{
|
||||
@ -94,7 +94,7 @@ Turns method data providers in PHPUnit from arrays to yield
|
||||
$someObject = new SomeClass;
|
||||
-$someObject->oldMethod();
|
||||
+$someObject->newMethod();
|
||||
|
||||
|
||||
-SomeClass::oldStaticMethod();
|
||||
+SomeClass::newStaticMethod();
|
||||
```
|
||||
@ -173,11 +173,11 @@ Turns properties with @inject to private properties and constructor injection
|
||||
```diff
|
||||
/**
|
||||
* @var SomeService
|
||||
- * @inject
|
||||
- * @inject
|
||||
*/
|
||||
- public $someService;
|
||||
+ private $someService;
|
||||
+
|
||||
+
|
||||
+ public function __construct(SomeService $someService)
|
||||
+ {
|
||||
+ $this->someService = $someService;
|
||||
@ -210,7 +210,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 extends \Nette\Object { }
|
||||
+class SomeClass { use Nette\SmartObject; }
|
||||
```
|
||||
|
||||
@ -262,7 +262,7 @@ Turns expand() to parameters value in Nette\DI\CompilerExtension
|
||||
```diff
|
||||
-$builder->expand("argument");
|
||||
+$builder->parameters["argument"];
|
||||
|
||||
|
||||
-$builder->expand("%argument%");
|
||||
+$builder->parameters["argument"];
|
||||
```
|
||||
@ -315,7 +315,7 @@ 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);
|
||||
```
|
||||
@ -328,7 +328,7 @@ Turns magic callback assign to callback assign on Nette Form events.
|
||||
```diff
|
||||
-isset($container["someKey"]);
|
||||
+$container->hasService("someKey");
|
||||
|
||||
|
||||
-unset($container["someKey"])
|
||||
+$container->removeService("someKey");
|
||||
```
|
||||
@ -351,7 +351,7 @@ 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;
|
||||
```
|
||||
@ -394,7 +394,7 @@ Turns use property to method and $node->alias to last name in UseAlias Node of P
|
||||
```diff
|
||||
-$node->alias;
|
||||
+$node->getAlias();
|
||||
|
||||
|
||||
-$node->name->getLast();
|
||||
+$node->alias
|
||||
```
|
||||
@ -427,7 +427,7 @@ 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");
|
||||
```
|
||||
@ -440,7 +440,7 @@ 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");
|
||||
```
|
||||
@ -463,7 +463,7 @@ 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);
|
||||
```
|
||||
@ -476,7 +476,7 @@ 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");
|
||||
```
|
||||
@ -489,7 +489,7 @@ 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");
|
||||
```
|
||||
@ -502,16 +502,16 @@ 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")
|
||||
```
|
||||
@ -524,7 +524,7 @@ 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");
|
||||
```
|
||||
@ -537,7 +537,7 @@ 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");
|
||||
```
|
||||
@ -550,7 +550,7 @@ 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");
|
||||
```
|
||||
@ -563,7 +563,7 @@ 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);
|
||||
```
|
||||
@ -575,9 +575,9 @@ Takes setExpectedException() 2nd and next arguments to own methods in PHPUnit.
|
||||
|
||||
```diff
|
||||
-$this->setExpectedException(Exception::class, "Message", "CODE");
|
||||
+ $this->setExpectedException(Exception::class);
|
||||
+ $this->expectExceptionMessage("Message");
|
||||
+ $this->expectExceptionCode("CODE");
|
||||
+$this->setExpectedException(Exception::class);
|
||||
+$this->expectExceptionMessage("Message");
|
||||
+$this->expectExceptionCode("CODE");
|
||||
```
|
||||
|
||||
|
||||
@ -588,7 +588,7 @@ Turns getMock*() methods to createMock()
|
||||
```diff
|
||||
-$this->getMock("Class")
|
||||
+$this->createMock("Class")
|
||||
|
||||
|
||||
-$this->getMockWithoutInvokingTheOriginalConstructor("Class")
|
||||
+$this->createMock("Class"
|
||||
```
|
||||
@ -610,9 +610,9 @@ Takes setExpectedException() 2nd and next arguments to own methods in PHPUnit.
|
||||
|
||||
```diff
|
||||
-$this->setExpectedException(Exception::class, "Message", "CODE");
|
||||
+ $this->setExpectedException(Exception::class);
|
||||
+ $this->expectExceptionMessage("Message");
|
||||
+ $this->expectExceptionCode("CODE");
|
||||
+$this->setExpectedException(Exception::class);
|
||||
+$this->expectExceptionMessage("Message");
|
||||
+$this->expectExceptionCode("CODE");
|
||||
```
|
||||
|
||||
|
||||
@ -710,7 +710,7 @@ Turns fetching of parameters via getParmaeter() in ContainerAware to constructor
|
||||
+ {
|
||||
+ $this->someParameter = $someParameter;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
public function someMethod()
|
||||
{
|
||||
- $this->getParameter('someParameter');
|
||||
@ -768,19 +768,15 @@ Turns long flash adding to short helper method in Controller in Symfony
|
||||
Turns fetching of dependencies via $this->get() to constructor injection in Command and Controller in Symfony
|
||||
|
||||
```diff
|
||||
-class MyCommand extends ContainerAwareCommand
|
||||
+class MyCommand extends Command
|
||||
{
|
||||
+ public function __construct(SomeService $someService)
|
||||
+ {
|
||||
+ $this->someService = $someService;
|
||||
+ }
|
||||
+use Symfony\Component\HttpFoundation\Request;
|
||||
+
|
||||
public function someMethod()
|
||||
class SomeController
|
||||
{
|
||||
- public function someAction()
|
||||
+ public action(Request $request)
|
||||
{
|
||||
- // ...
|
||||
- $this->get('some_service');
|
||||
+ $this->someService;
|
||||
- $this->getRequest()->...();
|
||||
+ $request->...();
|
||||
}
|
||||
}
|
||||
```
|
||||
@ -793,7 +789,7 @@ Turns string Form Type references to their CONSTANT alternatives in getParent()
|
||||
```diff
|
||||
-function getParent() { return "collection"; }
|
||||
+function getParent() { return CollectionType::class; }
|
||||
|
||||
|
||||
-function getExtendedType() { return "collection"; }
|
||||
+function getExtendedType() { return CollectionType::class; }
|
||||
```
|
||||
@ -816,7 +812,7 @@ 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
|
||||
```
|
||||
@ -859,7 +855,7 @@ Adds new $format argument in VarDumperTestTrait->assertDumpEquals() in in Valida
|
||||
```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 = "");
|
||||
```
|
||||
@ -890,10 +886,9 @@ Turns ProcessBuilder::instance() to new ProcessBuilder in Process in Symfony. Pa
|
||||
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;
|
||||
- $process = $processBuilder->getProcess();
|
||||
- $commamdLine = $processBuilder->getProcess()->getCommandLine();
|
||||
+$processBuilder = new Symfony\Component\Process\ProcessBuilder;
|
||||
$processBuilder = new Symfony\Component\Process\ProcessBuilder;
|
||||
-$process = $processBuilder->getProcess();
|
||||
-$commamdLine = $processBuilder->getProcess()->getCommandLine();
|
||||
+$process = $processBuilder;
|
||||
+$commamdLine = $processBuilder->getCommandLine();
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user