Skip to content

Commit

Permalink
[automated] Re-Generate Nodes/Rectors Documentation (#1612)
Browse files Browse the repository at this point in the history
Co-authored-by: TomasVotruba <TomasVotruba@users.noreply.github.com>
  • Loading branch information
TomasVotruba and TomasVotruba committed Jan 2, 2022
1 parent 7ba13ad commit 9c6a6b0
Showing 1 changed file with 110 additions and 22 deletions.
132 changes: 110 additions & 22 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 508 Rules Overview
# 512 Rules Overview

<br>

Expand Down Expand Up @@ -26,9 +26,9 @@

- [DowngradePhp55](#downgradephp55) (4)

- [DowngradePhp56](#downgradephp56) (4)
- [DowngradePhp56](#downgradephp56) (5)

- [DowngradePhp70](#downgradephp70) (14)
- [DowngradePhp70](#downgradephp70) (15)

- [DowngradePhp71](#downgradephp71) (10)

Expand All @@ -38,7 +38,7 @@

- [DowngradePhp74](#downgradephp74) (12)

- [DowngradePhp80](#downgradephp80) (25)
- [DowngradePhp80](#downgradephp80) (26)

- [DowngradePhp81](#downgradephp81) (8)

Expand Down Expand Up @@ -74,7 +74,7 @@

- [Php73](#php73) (9)

- [Php74](#php74) (14)
- [Php74](#php74) (15)

- [Php80](#php80) (18)

Expand Down Expand Up @@ -4077,6 +4077,30 @@ Replace argument unpacking by `call_user_func_array()`

<br>

### DowngradeArrayFilterUseConstantRector

Replace use ARRAY_FILTER_USE_BOTH and ARRAY_FILTER_USE_KEY to loop to filter it

- class: [`Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector`](../rules/DowngradePhp56/Rector/FuncCall/DowngradeArrayFilterUseConstantRector.php)

```diff
$arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4];

-var_dump(array_filter($arr, function($v, $k) {
- return $k == 'b' || $v == 4;
-}, ARRAY_FILTER_USE_BOTH));
+$result = [];
+foreach ($arr as $k => $v) {
+ if ($v === 4 || $k === 'b') {
+ $result[$k] = $v;
+ }
+}
+
+var_dump($result);
```

<br>

### DowngradeExponentialAssignmentOperatorRector

Remove exponential assignment operator **=
Expand Down Expand Up @@ -4291,14 +4315,17 @@ Remove the type params and return type, add `@param` and `@return` tags instead

### DowngradeSelfTypeDeclarationRector

Remove "self" return type, add a `"@return` self" tag instead
Remove "self" return type, add a `"@return` `$this"` tag instead

- class: [`Rector\DowngradePhp70\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector`](../rules/DowngradePhp70/Rector/ClassMethod/DowngradeSelfTypeDeclarationRector.php)

```diff
class SomeClass
{
- public function foo(): self
+ /**
+ * @return $this
+ */
+ public function foo()
{
return $this;
Expand Down Expand Up @@ -4356,6 +4383,29 @@ Remove the declare(strict_types=1)

<br>

### DowngradeThrowableTypeDeclarationRector

Replace `Throwable` type hints by PHPDoc tags

- class: [`Rector\DowngradePhp70\Rector\FunctionLike\DowngradeThrowableTypeDeclarationRector`](../rules/DowngradePhp70/Rector/FunctionLike/DowngradeThrowableTypeDeclarationRector.php)

```diff
class SomeClass
{
- public function foo(\Throwable $e): ?\Throwable
+ /**
+ * @param \Throwable $e
+ * @return \Throwable|null
+ */
+ public function foo($e)
{
return new \Exception("Troubles");
}
}
```

<br>

### SplitGroupedUseImportsRector

Refactor grouped use imports to standalone lines
Expand Down Expand Up @@ -5132,6 +5182,26 @@ Replace arbitrary expressions used with new or instanceof.

<br>

### DowngradeArrayFilterNullableCallbackRector

Unset nullable callback on array_filter

- class: [`Rector\DowngradePhp80\Rector\FuncCall\DowngradeArrayFilterNullableCallbackRector`](../rules/DowngradePhp80/Rector/FuncCall/DowngradeArrayFilterNullableCallbackRector.php)

```diff
class SomeClass
{
public function run($callback = null)
{
$data = [[]];
- var_dump(array_filter($data, null));
+ var_dump(array_filter($data));
}
}
```

<br>

### DowngradeAttributeToAnnotationRector

Refactor PHP attribute markers to annotations notation
Expand Down Expand Up @@ -7783,6 +7853,31 @@ Change deprecated (real) to (float)

<br>

### ReservedFnFunctionRector

Change `fn()` function name to `f()`, since it will be reserved keyword

- class: [`Rector\Php74\Rector\Function_\ReservedFnFunctionRector`](../rules/Php74/Rector/Function_/ReservedFnFunctionRector.php)

```diff
class SomeClass
{
public function run()
{
- function fn($value)
+ function f($value)
{
return $value;
}

- fn(5);
+ f(5);
}
}
```

<br>

### RestoreDefaultNullToNullableTypePropertyRector

Add null default to properties with PHP 7.4 property nullable type
Expand Down Expand Up @@ -11070,43 +11165,36 @@ return static function (ContainerConfigurator $containerConfigurator): void {

<br>

### ReservedFnFunctionRector
### ReturnTypeWillChangeRector

Change `fn()` function name, since it will be reserved keyword
Add #[\ReturnTypeWillChange] attribute to configured instanceof class with methods

:wrench: **configure it!**

- class: [`Rector\Transform\Rector\Function_\ReservedFnFunctionRector`](../rules/Transform/Rector/Function_/ReservedFnFunctionRector.php)
- class: [`Rector\Transform\Rector\ClassMethod\ReturnTypeWillChangeRector`](../rules/Transform/Rector/ClassMethod/ReturnTypeWillChangeRector.php)

```php
use Rector\Transform\Rector\Function_\ReservedFnFunctionRector;
use Rector\Transform\Rector\ClassMethod\ReturnTypeWillChangeRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->set(ReservedFnFunctionRector::class)
$services->set(ReturnTypeWillChangeRector::class)
->configure([
'fn' => 'someFunctionName',
ArrayAccess::class => ['offsetGet'],
]);
};
```


```diff
class SomeClass
class SomeClass implements ArrayAccess
{
public function run()
+ #[\ReturnTypeWillChange]
public function offsetGet($offset)
{
- function fn($value)
+ function f($value)
{
return $value;
}

- fn(5);
+ f(5);
}
}
```
Expand Down

0 comments on commit 9c6a6b0

Please sign in to comment.