diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 0ec90651..b8ab9084 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -1,4 +1,4 @@ -# 87 Rules Overview +# 88 Rules Overview ## AbortIfRector diff --git a/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php b/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php index ea0177da..7736467a 100644 --- a/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php +++ b/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php @@ -3,7 +3,6 @@ namespace RectorLaravel\Rector\StaticCall; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\StaticCall; @@ -137,11 +136,13 @@ private function createDispatchableCall(StaticCall $staticCall, string $method): return null; } - return new FuncCall( - new Name($method), - [ - new Arg(new New_(new FullyQualified($class), $staticCall->args)), - ], + $className = $class->isSpecialClassName() + ? $class + : new FullyQualified($class); + + return $this->nodeFactory->createFuncCall( + $method, + [new New_($className, $staticCall->args)], ); } } diff --git a/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable_within_self.php.inc b/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable_within_self.php.inc new file mode 100644 index 00000000..421f518f --- /dev/null +++ b/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable_within_self.php.inc @@ -0,0 +1,31 @@ +