Skip to content

Commit 40926d1

Browse files
committed
1 parent 25949b9 commit 40926d1

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎config/set/rector-preset.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
declare(strict_types=1);
44

5-
use Rector\Utils\Rector\RemoveRefactorDuplicatedNodeInstanceCheckRector;
6-
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;
75
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
86
use Rector\Config\RectorConfig;
7+
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;
98
use Rector\Privatization\Rector\Class_\FinalizeTestCaseClassRector;
109
use Rector\TypeDeclaration\Rector\StmtsAwareInterface\DeclareStrictTypesRector;
10+
use Rector\Utils\Rector\RemoveRefactorDuplicatedNodeInstanceCheckRector;
1111

1212
return static function (RectorConfig $rectorConfig): void {
1313
$rectorConfig->rules([

‎rules/DeadCode/NodeAnalyzer/CallCollectionAnalyzer.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PhpParser\Node\Identifier;
1212
use PhpParser\Node\Name;
1313
use PHPStan\Type\MixedType;
14+
use PHPStan\Type\NeverType;
1415
use Rector\Enum\ObjectReference;
1516
use Rector\NodeNameResolver\NodeNameResolver;
1617
use Rector\NodeTypeResolver\NodeTypeResolver;
@@ -35,6 +36,12 @@ public function isExists(array $calls, string $classMethodName, string $classNam
3536

3637
$callerTypeClassName = ClassNameFromObjectTypeResolver::resolve($callerType);
3738
if ($callerTypeClassName === null) {
39+
// the caller scope is unreachable, e.g. behind mutual recursion, so the type
40+
// resolves to never; the call still exists in code, keep the method to be safe
41+
if ($callerType instanceof NeverType && $this->shouldSkip($call, $classMethodName)) {
42+
return true;
43+
}
44+
3845
// handle fluent by $this->bar()->baz()->qux()
3946
// that methods don't have return type
4047
if ($callerType instanceof MixedType && ! $callerType->isExplicitMixed()) {

0 commit comments

Comments
 (0)