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:
parent
bf67c036aa
commit
e551b24843
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user