Skip to content

Commit 76ec726

Browse files
committed
refactor(rules): Rename rule from RenameGarbageVariableNameRector to RenameGarbageParamNameRector
- Updates import statements in configuration files to reference RenameGarbageParamNameRector - Renames class files and namespaces accordingly - Modifies test references and baseline paths to match new class name - Ensures consistency across codebase for the renamed rule
1 parent f168f2d commit 76ec726

File tree

12 files changed

+24
-19
lines changed

12 files changed

+24
-19
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ composer require guanguans/rector-rules --dev --ansi -v
2929

3030
* [`Guanguans\RectorRules\Set\SetList::ALL`](src/Set/SetList.php)
3131
* [`Guanguans\RectorRules\Set\SetList::COMMON`](src/Set/SetList.php)
32+
* [`Guanguans\RectorRules\Set\SetList::LARAVEL_80`](src/Set/SetList.php)
33+
* [`Guanguans\RectorRules\Set\SetList::LARAVEL_90`](src/Set/SetList.php)
34+
* [`Guanguans\RectorRules\Set\SetList::LARAVEL_COMMON`](src/Set/SetList.php)
3235
* [`Guanguans\RectorRules\Set\SetList::PHPBENCH`](src/Set/SetList.php)
3336
* [`Guanguans\RectorRules\Set\SetList::PHPSTAN`](src/Set/SetList.php)
3437
* [`Guanguans\RectorRules\Set\SetList::RECTOR`](src/Set/SetList.php)
@@ -37,13 +40,14 @@ composer require guanguans/rector-rules --dev --ansi -v
3740

3841
```php
3942
use Guanguans\RectorRules\Rector\File\SortFileFunctionStmtRector;
43+
use Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageParamNameRector;
4044
use Guanguans\RectorRules\Rector\Name\RenameToConventionalCaseNameRector;
4145
use PhpParser\NodeVisitor\ParentConnectingVisitor;
4246
use Rector\Config\RectorConfig;
4347

4448
return RectorConfig::configure()
4549
->withSets([
46-
Guanguans\RectorRules\Set\SetList::ALL,
50+
Guanguans\RectorRules\Set\SetList::COMMON,
4751
// ...
4852
])
4953
// ...
@@ -55,6 +59,7 @@ return RectorConfig::configure()
5559
])
5660
// ...
5761
->withRules([
62+
RenameGarbageParamNameRector::class,
5863
SortFileFunctionStmtRector::class,
5964
// ...
6065
]);

baselines/method.nonObject.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ parameters:
1010
-
1111
message: '#^Cannot call method all\(\) on mixed\.$#'
1212
count: 1
13-
path: ../src/Rector/FunctionLike/RenameGarbageVariableNameRector.php
13+
path: ../src/Rector/FunctionLike/RenameGarbageParamNameRector.php
1414

1515
-
1616
message: '#^Cannot call method getParameterOption\(\) on mixed\.$#'

baselines/rector.avoidFeatureSetAttributeInRector.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ parameters:
55
-
66
message: '#^Instead of using Rector rule to setAttribute\("start_and_end"\) to be used later, create a service extending "DecoratingNodeVisitorInterface"\. This ensures attribute decoration and node changes are in 2 separated steps\.$#'
77
count: 1
8-
path: ../src/Rector/FunctionLike/RenameGarbageVariableNameRector.php
8+
path: ../src/Rector/FunctionLike/RenameGarbageParamNameRector.php

baselines/symplify.forbiddenFuncCall.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ parameters:
1515
-
1616
message: '#^Function "property_exists\(\)" cannot be used/left in the code$#'
1717
count: 1
18-
path: ../src/Rector/FunctionLike/RenameGarbageVariableNameRector.php
18+
path: ../src/Rector/FunctionLike/RenameGarbageParamNameRector.php
1919

2020
-
2121
message: '#^Function "property_exists\(\)" cannot be used/left in the code\: use ReflectionProvider\-\>has\*\(\) instead$#'
2222
count: 1
23-
path: ../src/Rector/FunctionLike/RenameGarbageVariableNameRector.php
23+
path: ../src/Rector/FunctionLike/RenameGarbageParamNameRector.php

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@
378378
"rector:process-clear-cache": "@rector:process --clear-cache",
379379
"rector:process-clear-cache-dry-run": "@rector:process-clear-cache --dry-run",
380380
"rector:process-dry-run": "@rector:process --dry-run",
381-
"rector:process-only": "@rector:process-clear-cache tests.php --only=Guanguans\\RectorRules\\Rector\\FunctionLike\\RenameGarbageVariableNameRector",
381+
"rector:process-only": "@rector:process-clear-cache tests.php --only=Guanguans\\RectorRules\\Rector\\FunctionLike\\RenameGarbageParamNameRector",
382382
"rector:process-only-dry-run": "@rector:process-only --dry-run",
383383
"rule-doc-generator": [
384384
"@putenv:php",
@@ -388,7 +388,7 @@
388388
"rule-doc-generator:validate": "@rule-doc-generator validate src/Rector/ src/Rector/Array_/UpdateRectorCodeSamplesFromFixturesRector.php",
389389
"sk": "@php vendor/bin/swiss-knife --ansi -vv",
390390
"sk:alice-yaml-fixtures-to-php": "@sk alice-yaml-fixtures-to-php --help",
391-
"sk:check-commented-code": "@sk check-commented-code src/ --line-limit=5 --skip-file=src/Support/helpers.php --skip-file=src/Rector/Name/RenameToConventionalCaseNameRector.php --skip-file=src/Rector/Array_/UpdateRectorCodeSamplesFromFixturesRector.php --skip-file=src/Rector/Class_/AbstractUpdateClassMethodNodeParamDocblockFromNodeTypesRector.php --skip-file=src/Rector/FunctionLike/RenameGarbageVariableNameRector.php",
391+
"sk:check-commented-code": "@sk check-commented-code src/ --line-limit=5 --skip-file=src/Support/helpers.php --skip-file=src/Rector/Name/RenameToConventionalCaseNameRector.php --skip-file=src/Rector/Array_/UpdateRectorCodeSamplesFromFixturesRector.php --skip-file=src/Rector/Class_/AbstractUpdateClassMethodNodeParamDocblockFromNodeTypesRector.php --skip-file=src/Rector/FunctionLike/RenameGarbageParamNameRector.php",
392392
"sk:check-conflicts": "@sk check-conflicts src/",
393393
"sk:dump-editorconfig": "@sk dump-editorconfig",
394394
"sk:finalize-classes": "@sk finalize-classes src/",

config/set/common.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
use Guanguans\RectorRules\Rector\Array_\SortListItemOfSameScalarTypeRector;
1818
use Guanguans\RectorRules\Rector\File\SortFileFirstStmtDocblockRector;
1919
use Guanguans\RectorRules\Rector\File\SortFileFunctionStmtRector;
20-
use Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageVariableNameRector;
20+
use Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageParamNameRector;
2121
use Guanguans\RectorRules\Rector\Namespace_\RemoveNamespaceRector;
2222
use Rector\Config\RectorConfig;
2323

2424
return static function (RectorConfig $rectorConfig): void {
2525
$rectorConfig->import(__DIR__.'/../config.php');
2626
$rectorConfig->rules([
2727
RemoveNamespaceRector::class,
28-
RenameGarbageVariableNameRector::class,
28+
RenameGarbageParamNameRector::class,
2929
SimplifyListIndexRector::class,
3030
SortFileFirstStmtDocblockRector::class,
3131
SortFileFunctionStmtRector::class,

docs/rules-overview.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,11 @@ Sort file function stmt
250250

251251
## FunctionLike
252252

253-
### RenameGarbageVariableNameRector
253+
### RenameGarbageParamNameRector
254254

255-
Rename garbage variable name
255+
Rename garbage param name
256256

257-
- class: [`Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageVariableNameRector`](../src/Rector/FunctionLike/RenameGarbageVariableNameRector.php)
257+
- class: [`Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageParamNameRector`](../src/Rector/FunctionLike/RenameGarbageParamNameRector.php)
258258

259259
```diff
260260
/** @noinspection ALL */

src/Rector/FunctionLike/RenameGarbageVariableNameRector.php renamed to src/Rector/FunctionLike/RenameGarbageParamNameRector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
3838

3939
/**
40-
* @see \Guanguans\RectorRulesTests\Rector\FunctionLike\RenameGarbageVariableNameRector\RenameGarbageVariableNameRectorTest
40+
* @see \Guanguans\RectorRulesTests\Rector\FunctionLike\RenameGarbageParamNameRector\RenameGarbageParamNameRectorTest
4141
*/
42-
final class RenameGarbageVariableNameRector extends AbstractRector
42+
final class RenameGarbageParamNameRector extends AbstractRector
4343
{
4444
private const GARBAGE_VARIABLE_NAME = '_';
4545
private BetterNodeFinder $betterNodeFinder;

tests/Rector/FunctionLike/RenameGarbageVariableNameRector/Fixture/fixture.php.inc renamed to tests/Rector/FunctionLike/RenameGarbageParamNameRector/Fixture/fixture.php.inc

File renamed without changes.

tests/Rector/FunctionLike/RenameGarbageVariableNameRector/Fixture/skips.php.inc renamed to tests/Rector/FunctionLike/RenameGarbageParamNameRector/Fixture/skips.php.inc

File renamed without changes.

0 commit comments

Comments
 (0)