mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 16:30:51 +00:00
[automated] Re-Generate Nodes/Rectors Documentation (#211)
Co-authored-by: TomasVotruba <TomasVotruba@users.noreply.github.com>
This commit is contained in:
parent
09251da597
commit
651562dca2
|
@ -172,42 +172,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
<br>
|
||||
|
||||
### ArgumentDefaultValueReplacerRector
|
||||
|
||||
Replaces defined map of arguments in defined methods and their calls.
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Arguments\Rector\ClassMethod\ArgumentDefaultValueReplacerRector`](../rules/Arguments/Rector/ClassMethod/ArgumentDefaultValueReplacerRector.php)
|
||||
|
||||
```php
|
||||
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(ReplaceArgumentDefaultValueRector::class)
|
||||
->call('configure', [[
|
||||
ReplaceArgumentDefaultValueRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
new ReplaceArgumentDefaultValue('SomeExampleClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', false),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
$someObject = new SomeClass;
|
||||
-$someObject->someMethod(SomeClass::OLD_CONSTANT);
|
||||
+$someObject->someMethod(false);'
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### FunctionArgumentDefaultValueReplacerRector
|
||||
|
||||
Streamline the operator arguments of version_compare function
|
||||
|
@ -243,6 +207,42 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
|||
|
||||
<br>
|
||||
|
||||
### ReplaceArgumentDefaultValueRector
|
||||
|
||||
Replaces defined map of arguments in defined methods and their calls.
|
||||
|
||||
:wrench: **configure it!**
|
||||
|
||||
- class: [`Rector\Arguments\Rector\ClassMethod\ReplaceArgumentDefaultValueRector`](../rules/Arguments/Rector/ClassMethod/ReplaceArgumentDefaultValueRector.php)
|
||||
|
||||
```php
|
||||
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(ReplaceArgumentDefaultValueRector::class)
|
||||
->call('configure', [[
|
||||
ReplaceArgumentDefaultValueRector::REPLACED_ARGUMENTS => ValueObjectInliner::inline([
|
||||
new ReplaceArgumentDefaultValue('SomeExampleClass', 'someMethod', 0, 'SomeClass::OLD_CONSTANT', false),
|
||||
]),
|
||||
]]);
|
||||
};
|
||||
```
|
||||
|
||||
↓
|
||||
|
||||
```diff
|
||||
$someObject = new SomeClass;
|
||||
-$someObject->someMethod(SomeClass::OLD_CONSTANT);
|
||||
+$someObject->someMethod(false);'
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
### SwapFuncCallArgumentsRector
|
||||
|
||||
Swap arguments in function calls
|
||||
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue
Block a user