1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Classes that just reference themselves aren’t used

This commit is contained in:
Brown 2019-12-16 11:46:10 -05:00
parent bf67c036aa
commit e551b24843
2 changed files with 15 additions and 1 deletions

View File

@ -210,7 +210,9 @@ class StaticCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
$fq_class_name, $fq_class_name,
new CodeLocation($source, $stmt->class), new CodeLocation($source, $stmt->class),
$statements_analyzer->getSuppressedIssues(), $statements_analyzer->getSuppressedIssues(),
false $stmt->class instanceof PhpParser\Node\Name
&& !count($stmt->class->parts) !== 1
&& in_array(strtolower($stmt->class->parts[0]), ['self', 'static'], true)
)) { )) {
return false; return false;
} }

View File

@ -929,6 +929,18 @@ class UnusedCodeTest extends TestCase
}', }',
'error_message' => 'UnusedMethodCall', 'error_message' => 'UnusedMethodCall',
], ],
'unusedClassReferencesItself' => [
'<?php
class A {}
class AChild extends A {
public function __construct() {
self::foo();
}
public static function foo() : void {}
}',
'error_message' => 'UnusedClass',
],
]; ];
} }
} }