Skip to content
Permalink
Browse files

Classes that just reference themselves aren’t used

  • Loading branch information
muglug committed Dec 16, 2019
1 parent bf67c03 commit e551b248436723439c863f70569f43cc479fb67e
@@ -210,7 +210,9 @@ public static function analyze(
$fq_class_name,
new CodeLocation($source, $stmt->class),
$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;
}
@@ -929,6 +929,18 @@ function foo(DateTimeImmutable $dt) : void {
}',
'error_message' => 'UnusedMethodCall',
],
'unusedClassReferencesItself' => [
'<?php
class A {}
class AChild extends A {
public function __construct() {
self::foo();
}
public static function foo() : void {}
}',
'error_message' => 'UnusedClass',
],
];
}
}

0 comments on commit e551b24

Please sign in to comment.
You can’t perform that action at this time.