Skip to content

Commit

Permalink
[automated] Re-Generate Nodes/Rectors Documentation (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: TomasVotruba <TomasVotruba@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and TomasVotruba authored Jun 13, 2021
1 parent 09251da commit 651562d
Showing 1 changed file with 36 additions and 45 deletions.
81 changes: 36 additions & 45 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,27 @@ return static function (ContainerConfigurator $containerConfigurator): void {

<br>

### ArgumentDefaultValueReplacerRector
### FunctionArgumentDefaultValueReplacerRector

Replaces defined map of arguments in defined methods and their calls.
Streamline the operator arguments of version_compare function

:wrench: **configure it!**

- class: [`Rector\Arguments\Rector\ClassMethod\ArgumentDefaultValueReplacerRector`](../rules/Arguments/Rector/ClassMethod/ArgumentDefaultValueReplacerRector.php)
- class: [`Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector`](../rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php)

```php
use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue;
use Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector;
use Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;

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

$services->set(ReplaceArgumentDefaultValueRector::class)
$services->set(FunctionArgumentDefaultValueReplacerRector::class)
->call('configure', [[
ReplaceArgumentDefaultValueRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
new ReplaceArgumentDefaultValue('SomeExampleClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', false),
FunctionArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'),
]),
]]);
};
Expand All @@ -201,34 +201,33 @@ return static function (ContainerConfigurator $containerConfigurator): void {

```diff
$someObject = new SomeClass;
-$someObject->someMethod(SomeClass::OLD_CONSTANT);
+$someObject->someMethod(false);'
-version_compare(PHP_VERSION, '5.6', 'gte');
+version_compare(PHP_VERSION, '5.6', 'ge');
```

<br>

### FunctionArgumentDefaultValueReplacerRector
### ReplaceArgumentDefaultValueRector

Streamline the operator arguments of version_compare function
Replaces defined map of arguments in defined methods and their calls.

:wrench: **configure it!**

- class: [`Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector`](../rules/Arguments/Rector/FuncCall/FunctionArgumentDefaultValueReplacerRector.php)
- class: [`Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector`](../rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php)

```php
use Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector;
use Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue;
use Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector;
use Rector\Arguments\ValueObject\ReplaceArgumentDefaultValue;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;

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

$services->set(FunctionArgumentDefaultValueReplacerRector::class)
$services->set(ReplaceArgumentDefaultValueRector::class)
->call('configure', [[
FunctionArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'),
ReplaceArgumentDefaultValueRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
new ReplaceArgumentDefaultValue('SomeExampleClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', false),
]),
]]);
};
Expand All @@ -237,8 +236,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {

```diff
-version_compare(PHP_VERSION, '5.6', 'gte');
+version_compare(PHP_VERSION, '5.6', 'ge');
$someObject = new SomeClass;
-$someObject->someMethod(SomeClass::OLD_CONSTANT);
+$someObject->someMethod(false);'
```

<br>
Expand Down Expand Up @@ -8138,30 +8138,21 @@ Change `switch()` to `match()`
- class: [`Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector`](../rules/Php80/Rector/Switch_/ChangeSwitchToMatchRector.php)

```diff
class SomeClass
{
public function run()
{
- switch ($this->lexer->lookahead['type']) {
- case Lexer::T_SELECT:
- $statement = $this->SelectStatement();
- break;
-
- case Lexer::T_UPDATE:
- $statement = $this->UpdateStatement();
- break;
-
- default:
- $statement = $this->syntaxError('SELECT, UPDATE or DELETE');
- break;
- }
+ $statement = match ($this->lexer->lookahead['type']) {
+ Lexer::T_SELECT => $this->SelectStatement(),
+ Lexer::T_UPDATE => $this->UpdateStatement(),
+ default => $this->syntaxError('SELECT, UPDATE or DELETE'),
+ };
}
}
-switch ($input) {
- case Lexer::T_SELECT:
- $statement = 'select';
- break;
- case Lexer::T_UPDATE:
- $statement = 'update';
- break;
- default:
- $statement = 'error';
-}
+$statement = match ($input) {
+ Lexer::T_SELECT => 'select',
+ Lexer::T_UPDATE => 'update',
+ default => 'error',
+};
```

<br>
Expand Down

0 comments on commit 651562d

Please sign in to comment.