Skip to content

Commit

Permalink
Use FullyQualified for class instead of Name (#225)
Browse files Browse the repository at this point in the history
* Use FullyQualified for class instead of Name

This ensures a leading slash '\' is added to the namespace, ensuring the namespace is loaded from the root and not relative to the current namespace.

* Run rector

* CS

---------

Co-authored-by: Geni Jaho <jahogeni@gmail.com>
  • Loading branch information
megawubs and GeniJaho authored Jul 7, 2024
1 parent 85f7ad4 commit c8e28db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Rector/StaticCall/DispatchToHelperFunctionsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PHPStan\Broker\ClassNotFoundException;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
Expand Down Expand Up @@ -128,7 +129,7 @@ private function createDispatchableCall(StaticCall $staticCall, string $method):
return new FuncCall(
new Name($method),
[
new Arg(new New_(new Name($class), $staticCall->args)),
new Arg(new New_(new FullyQualified($class), $staticCall->args)),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\

use RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob;

dispatch(new RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob('param1', 'param2'));
dispatch(new \RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob('param1', 'param2'));
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\

use RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestEvent;

event(new RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestEvent('param1', 'param2'));
event(new \RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestEvent('param1', 'param2'));

0 comments on commit c8e28db

Please sign in to comment.