mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-15 21:38:24 +01:00
Merge pull request #2099 from gnutix/ImportFullyQualifiedNamesRector/code-sample
Add documentation for ImportFullyQualifiedNamesRector new argument
This commit is contained in:
commit
7b55a5343a
@ -1,4 +1,4 @@
|
||||
# All 367 Rectors Overview
|
||||
# All 369 Rectors Overview
|
||||
|
||||
- [Projects](#projects)
|
||||
- [General](#general)
|
||||
@ -1235,6 +1235,7 @@ Import fully qualified names to use statements
|
||||
|
||||
```diff
|
||||
+use SomeAnother\AnotherClass;
|
||||
+use DateTime;
|
||||
+
|
||||
class SomeClass
|
||||
{
|
||||
@ -1243,6 +1244,38 @@ Import fully qualified names to use statements
|
||||
- return SomeAnother\AnotherClass;
|
||||
+ return AnotherClass;
|
||||
}
|
||||
|
||||
public function createDate()
|
||||
{
|
||||
- return new \DateTime();
|
||||
+ return new DateTime();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```yaml
|
||||
services:
|
||||
Rector\CodingStyle\Rector\Namespace_\ImportFullyQualifiedNamesRector:
|
||||
$shouldImportRootNamespaceClasses: false
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
+use SomeAnother\AnotherClass;
|
||||
+
|
||||
class SomeClass
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
- return SomeAnother\AnotherClass;
|
||||
+ return AnotherClass;
|
||||
}
|
||||
|
||||
public function createDate()
|
||||
{
|
||||
return new \DateTime(); // this remains untouched
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@ -1369,7 +1402,7 @@ services:
|
||||
|
||||
- class: `Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector`
|
||||
|
||||
Removes unused use aliases
|
||||
Removes unused use aliases. Keep annotation aliases like "Doctrine\ORM\Mapping as ORM" to keep convention format
|
||||
|
||||
```diff
|
||||
-use Symfony\Kernel as BaseKernel;
|
||||
@ -1532,6 +1565,25 @@ Prefer quote that not inside the string
|
||||
|
||||
<br>
|
||||
|
||||
### `UseIncrementAssignRector`
|
||||
|
||||
- class: `Rector\CodingStyle\Rector\Assign\UseIncrementAssignRector`
|
||||
|
||||
Use ++ increment instead of $var += 1.
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
- $style += 1;
|
||||
+ ++$style
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### `VarConstantCommentRector`
|
||||
|
||||
- class: `Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector`
|
||||
@ -1983,6 +2035,26 @@ Removes method that set values that are never used
|
||||
|
||||
<br>
|
||||
|
||||
### `RemoveUnreachableStatementRector`
|
||||
|
||||
- class: `Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector`
|
||||
|
||||
Remove unreachable statements
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
return 5;
|
||||
-
|
||||
- $removeMe = 10;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### `RemoveUnusedDoctrineEntityMethodAndPropertyRector`
|
||||
|
||||
- class: `Rector\DeadCode\Rector\Class_\RemoveUnusedDoctrineEntityMethodAndPropertyRector`
|
||||
@ -3869,7 +3941,7 @@ Remove 0 from break and continue
|
||||
|
||||
- class: `Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector`
|
||||
|
||||
The /e modifier is no longer supported, use preg_replace_callback instead
|
||||
The /e modifier is no longer supported, use preg_replace_callback instead
|
||||
|
||||
```diff
|
||||
class SomeClass
|
||||
|
@ -917,7 +917,7 @@ if (true) {
|
||||
|
||||
```php
|
||||
?>
|
||||
<strong>feel</strong><?php
|
||||
<strong>feel</strong><?php
|
||||
```
|
||||
<br>
|
||||
|
||||
|
@ -7,6 +7,7 @@ use PhpParser\Node\Name;
|
||||
use Rector\CodingStyle\Node\NameImporter;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
/**
|
||||
@ -50,6 +51,45 @@ class SomeClass
|
||||
{
|
||||
return SomeAnother\AnotherClass;
|
||||
}
|
||||
|
||||
public function createDate()
|
||||
{
|
||||
return new \DateTime();
|
||||
}
|
||||
}
|
||||
PHP
|
||||
,
|
||||
<<<'PHP'
|
||||
use SomeAnother\AnotherClass;
|
||||
use DateTime;
|
||||
|
||||
class SomeClass
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return AnotherClass;
|
||||
}
|
||||
|
||||
public function createDate()
|
||||
{
|
||||
return new DateTime();
|
||||
}
|
||||
}
|
||||
PHP
|
||||
),
|
||||
new ConfiguredCodeSample(
|
||||
<<<'PHP'
|
||||
class SomeClass
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return SomeAnother\AnotherClass;
|
||||
}
|
||||
|
||||
public function createDate()
|
||||
{
|
||||
return new \DateTime(); // this remains untouched
|
||||
}
|
||||
}
|
||||
PHP
|
||||
,
|
||||
@ -60,10 +100,19 @@ class SomeClass
|
||||
{
|
||||
public function create()
|
||||
{
|
||||
return AnotherClass;
|
||||
return AnotherClass;
|
||||
}
|
||||
|
||||
public function createDate()
|
||||
{
|
||||
return new \DateTime(); // this remains untouched
|
||||
}
|
||||
}
|
||||
PHP
|
||||
,
|
||||
[
|
||||
'$shouldImportRootNamespaceClasses' => false,
|
||||
]
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user