Skip to content

Commit c8e28db

Browse files
megawubsGeniJaho
andauthored
Use FullyQualified for class instead of Name (#225)
* 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 <[email protected]>
1 parent 85f7ad4 commit c8e28db

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Rector/StaticCall/DispatchToHelperFunctionsRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node\Expr\New_;
99
use PhpParser\Node\Expr\StaticCall;
1010
use PhpParser\Node\Name;
11+
use PhpParser\Node\Name\FullyQualified;
1112
use PHPStan\Broker\ClassNotFoundException;
1213
use PHPStan\Reflection\ClassReflection;
1314
use PHPStan\Reflection\ReflectionProvider;
@@ -128,7 +129,7 @@ private function createDispatchableCall(StaticCall $staticCall, string $method):
128129
return new FuncCall(
129130
new Name($method),
130131
[
131-
new Arg(new New_(new Name($class), $staticCall->args)),
132+
new Arg(new New_(new FullyQualified($class), $staticCall->args)),
132133
],
133134
);
134135
}

tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\
1212

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

15-
dispatch(new RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob('param1', 'param2'));
15+
dispatch(new \RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob('param1', 'param2'));

tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/event_dispatchable.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\
1212

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

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

0 commit comments

Comments
 (0)