Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 87 Rules Overview
# 88 Rules Overview

## AbortIfRector

Expand Down
13 changes: 7 additions & 6 deletions src/Rector/StaticCall/DispatchToHelperFunctionsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)],
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Fixture;

use Illuminate\Foundation\Bus\Dispatchable;

class BusDispatchableWithinSelf
{
use Dispatchable;

public function handle()
{
self::dispatch();
}
}
-----
<?php

namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Fixture;

use Illuminate\Foundation\Bus\Dispatchable;

class BusDispatchableWithinSelf
{
use Dispatchable;

public function handle()
{
dispatch(new self());
}
}