Skip to content

Commit

Permalink
[Transform] Allow transform ruleWithConfiguration() to withConfigured…
Browse files Browse the repository at this point in the history
…Rule() on RectorConfigBuilderRector (#5637)
  • Loading branch information
samsonasik committed Feb 19, 2024
1 parent a3d2375 commit d5c3fc7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig
->ruleWithConfiguration(RenameFunctionRector::class, [
'is_real' => 'is_float',
]);
};

?>
-----
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;

return \Rector\Config\RectorConfig::configure()->withConfiguredRule(RenameFunctionRector::class, [
'is_real' => 'is_float',
]);

?>
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ public function refactor(Node $node): ?Node
} elseif ($name === 'bootstrapFiles') {
Assert::isAOf($value, Array_::class);
$bootstrapFiles = $value;
} elseif ($name === 'ruleWithConfiguration') {
$newExpr = $this->nodeFactory->createMethodCall($newExpr, 'withConfiguredRule', [$value, $args[1]->value]);
$hasChanged = true;
} else {
// implementing method by method
return null;
Expand Down

0 comments on commit d5c3fc7

Please sign in to comment.