update rectors docs

This commit is contained in:
Tomas Votruba 2019-10-15 16:46:31 +02:00
parent a40831a825
commit f81bc8f8f0

View File

@ -1,4 +1,4 @@
# All 370 Rectors Overview
# All 380 Rectors Overview
- [Projects](#projects)
- [General](#general)
@ -45,6 +45,7 @@
- [Sensio](#sensio)
- [Shopware](#shopware)
- [Silverstripe](#silverstripe)
- [StrictCodeQuality](#strictcodequality)
- [Sylius](#sylius)
- [Symfony](#symfony)
- [SymfonyCodeQuality](#symfonycodequality)
@ -1241,6 +1242,36 @@ include/require should be followed by absolute path
<br>
### `FunctionCallToConstantRector`
- class: `Rector\CodingStyle\Rector\FuncCall\FunctionCallToConstantRector`
Changes use of function calls to use constants
```diff
class SomeClass
{
public function run()
{
- $value = php_sapi_name();
+ $value = PHP_SAPI;
}
}
```
```diff
class SomeClass
{
public function run()
{
- $value = pi();
+ $value = M_PI;
}
}
```
<br>
### `IdenticalFalseToBooleanNotRector`
- class: `Rector\CodingStyle\Rector\Identical\IdenticalFalseToBooleanNotRector`
@ -1629,6 +1660,25 @@ Constant should have a @var comment with type
<br>
### `VersionCompareFuncCallToConstantRector`
- class: `Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector`
Changes use of call to version compare function to use of PHP version constant
```diff
class SomeClass
{
public function run()
{
- version_compare(PHP_VERSION, '5.3.0', '<');
+ PHP_VERSION_ID < 50300;
}
}
```
<br>
### `YieldClassMethodToArrayClassMethodRector`
- class: `Rector\CodingStyle\Rector\ClassMethod\YieldClassMethodToArrayClassMethodRector`
@ -2226,6 +2276,29 @@ Remove unused private properties
<br>
### `SimplifyIfElseWithSameContentRector`
- class: `Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector`
Remove if/else if they have same content
```diff
class SomeClass
{
public function run()
{
- if (true) {
- return 1;
- } else {
- return 1;
- }
+ return 1;
}
}
```
<br>
### `SimplifyMirrorAssignRector`
- class: `Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector`
@ -3229,6 +3302,27 @@ Removes non-existing @var annotations above the code
## PHPUnit
### `AddDoesNotPerformAssertionToNonAssertingTestRector`
- class: `Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector`
Tests without assertion will have @doesNotPerformAssertion
```diff
class SomeClass extends PHPUnit\Framework\TestCase
{
+ /**
+ * @doesNotPerformAssertion
+ */
public function test()
{
$nothing = 5;
}
}
```
<br>
### `AddSeeTestAnnotationRector`
- class: `Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector`
@ -3545,6 +3639,28 @@ Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.
<br>
### `EnsureDataProviderInDocBlockRector`
- class: `Rector\PHPUnit\Rector\ClassMethod\EnsureDataProviderInDocBlockRector`
Data provider annotation must be in doc block
```diff
class SomeClass extends PHPUnit\Framework\TestCase
{
- /*
+ /**
* @dataProvider testProvideData()
*/
public function test()
{
$nothing = 5;
}
}
```
<br>
### `ExceptionAnnotationRector`
- class: `Rector\PHPUnit\Rector\ExceptionAnnotationRector`
@ -3566,6 +3682,28 @@ Takes `setExpectedException()` 2nd and next arguments to own methods in PHPUnit.
<br>
### `FixDataProviderAnnotationTypoRector`
- class: `Rector\PHPUnit\Rector\ClassMethod\FixDataProviderAnnotationTypoRector`
Fix data provider annotation typos
```diff
class SomeClass extends \PHPUnit\Framework\TestCase
{
/**
- * @dataProvidor testProvideData()
+ * @dataProvider testProvideData()
*/
public function test()
{
$nothing = 5;
}
}
```
<br>
### `GetMockRector`
- class: `Rector\PHPUnit\Rector\GetMockRector`
@ -3584,6 +3722,34 @@ Turns getMock*() methods to createMock()
<br>
### `RemoveDataProviderTestPrefixRector`
- class: `Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector`
Data provider methods cannot start with "test" prefix
```diff
class SomeClass extends PHPUnit\Framework\TestCase
{
/**
- * @dataProvider testProvideData()
+ * @dataProvider provideData()
*/
public function test()
{
$nothing = 5;
}
- public function testProvideData()
+ public function provideData()
{
return ['123'];
}
}
```
<br>
### `RemoveExpectAnyFromMockRector`
- class: `Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector`
@ -5832,6 +5998,32 @@ Finalize every class constant that is used only locally
<br>
### `UseInterfaceOverImplementationInConstructorRector`
- class: `Rector\SOLID\Rector\ClassMethod\UseInterfaceOverImplementationInConstructorRector`
Use interface instead of specific class
```diff
class SomeClass
{
- public function __construct(SomeImplementation $someImplementation)
+ public function __construct(SomeInterface $someImplementation)
{
}
}
class SomeImplementation implements SomeInterface
{
}
interface SomeInterface
{
}
```
<br>
## Sensio
### `TemplateAnnotationRector`
@ -5940,6 +6132,28 @@ Turns defined function call to static method call.
<br>
## StrictCodeQuality
### `VarInlineAnnotationToAssertRector`
- class: `Rector\StrictCodeQuality\Rector\Stmt\VarInlineAnnotationToAssertRector`
Turn @var inline checks above code to assert() of hte type
```diff
class SomeClass
{
public function run()
{
/** @var SpecificClass $value */
+ assert($value instanceof SpecificClass);
$value->call();
}
}
```
<br>
## Sylius
### `ReplaceCreateMethodWithoutReviewerRector`
@ -6041,6 +6255,26 @@ Turns old event name with EXCEPTION to ERROR constant in Console in Symfony
<br>
### `ConsoleExecuteReturnIntRector`
- class: `Rector\Symfony\Rector\Console\ConsoleExecuteReturnIntRector`
Returns int from Command::execute command
```diff
class SomeCommand extends Command
{
- public function execute(InputInterface $input, OutputInterface $output)
+ public function index(InputInterface $input, OutputInterface $output): int
{
- return null;
+ return 0;
}
}
```
<br>
### `ConstraintUrlOptionRector`
- class: `Rector\Symfony\Rector\Validator\ConstraintUrlOptionRector`