mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
fix unused method type for return type (#1831)
fix unused method type for return type
This commit is contained in:
commit
c10d77d993
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\Fixture;
|
||||
|
||||
use stdClass;
|
||||
|
||||
final class KeepStaticEdge
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
return self::iAmUsed();
|
||||
}
|
||||
|
||||
private static function iAmUsed(): stdClass
|
||||
{
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\Fixture;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveUnusedPrivateMethodRector\Fixture;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
|
@ -14,6 +14,7 @@ final class RemoveUnusedPrivateMethodRectorTest extends AbstractRectorTestCase
|
||||
__DIR__ . '/Fixture/static_method.php.inc',
|
||||
__DIR__ . '/Fixture/private_constructor.php.inc',
|
||||
// skip
|
||||
__DIR__ . '/Fixture/keep_static_edge.php.inc',
|
||||
__DIR__ . '/Fixture/keep_anonymous.php.inc',
|
||||
__DIR__ . '/Fixture/skip_local_called.php.inc',
|
||||
__DIR__ . '/Fixture/keep_in_trait.php.inc',
|
||||
|
@ -576,7 +576,12 @@ final class ParsedNodesByType
|
||||
private function addCall(Node $node): void
|
||||
{
|
||||
// one node can be of multiple-class types
|
||||
$classTypes = $this->resolveNodeClassTypes($node);
|
||||
if ($node instanceof MethodCall) {
|
||||
$classTypes = $this->resolveNodeClassTypes($node->var);
|
||||
} else {
|
||||
$classTypes = $this->resolveNodeClassTypes($node->class);
|
||||
}
|
||||
|
||||
if ($classTypes === []) { // anonymous
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user