Skip to content

Commit e33d849

Browse files
authored
Merge branch 'main' into main
2 parents ec4c21d + f6d80de commit e33d849

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

docs/rector_rules_overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 87 Rules Overview
1+
# 88 Rules Overview
22

33
## AbortIfRector
44

src/Rector/StaticCall/DispatchToHelperFunctionsRector.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace RectorLaravel\Rector\StaticCall;
44

55
use PhpParser\Node;
6-
use PhpParser\Node\Arg;
76
use PhpParser\Node\Expr\FuncCall;
87
use PhpParser\Node\Expr\New_;
98
use PhpParser\Node\Expr\StaticCall;
@@ -137,11 +136,13 @@ private function createDispatchableCall(StaticCall $staticCall, string $method):
137136
return null;
138137
}
139138

140-
return new FuncCall(
141-
new Name($method),
142-
[
143-
new Arg(new New_(new FullyQualified($class), $staticCall->args)),
144-
],
139+
$className = $class->isSpecialClassName()
140+
? $class
141+
: new FullyQualified($class);
142+
143+
return $this->nodeFactory->createFuncCall(
144+
$method,
145+
[new New_($className, $staticCall->args)],
145146
);
146147
}
147148
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Fixture;
4+
5+
use Illuminate\Foundation\Bus\Dispatchable;
6+
7+
class BusDispatchableWithinSelf
8+
{
9+
use Dispatchable;
10+
11+
public function handle()
12+
{
13+
self::dispatch();
14+
}
15+
}
16+
-----
17+
<?php
18+
19+
namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Fixture;
20+
21+
use Illuminate\Foundation\Bus\Dispatchable;
22+
23+
class BusDispatchableWithinSelf
24+
{
25+
use Dispatchable;
26+
27+
public function handle()
28+
{
29+
dispatch(new self());
30+
}
31+
}

0 commit comments

Comments
 (0)