-
-
Notifications
You must be signed in to change notification settings - Fork 345
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support NullSafeMethod calls in unused-code analysis (#5838)
* Support NullSafeMethod calls in unused-code analysis * fix phpstan
- Loading branch information
Showing
3 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...r/ClassMethod/RemoveUnusedPrivateMethodRector/Fixture/keep_nullsafe_called_method.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\Fixture; | ||
|
||
final class KeepNullSafeCalledMethod | ||
{ | ||
private function privateMethod():void {} | ||
|
||
public function pubMethod() { | ||
$this->getX()?->privateMethod(); | ||
} | ||
|
||
public function getX(): KeepNullSafeCalledMethod|null { | ||
return rand(0,1) ? new KeepNullSafeCalledMethod() : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters