mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Cut down on interface PossiblyUnusedMethod reports
This commit is contained in:
parent
875bb8c072
commit
086b314df8
@ -346,6 +346,17 @@ class MethodChecker extends FunctionLikeChecker
|
||||
}
|
||||
$declaring_method_storage->referencing_locations[$code_location->file_path][] = $code_location;
|
||||
|
||||
foreach ($class_storage->class_implements as $fq_interface_name) {
|
||||
$interface_storage = $project_checker->classlike_storage_provider->get($fq_interface_name);
|
||||
if (isset($interface_storage->methods[$method_name])) {
|
||||
$interface_method_storage = $interface_storage->methods[$method_name];
|
||||
if (!isset($interface_method_storage->referencing_locations)) {
|
||||
$interface_method_storage->referencing_locations = [];
|
||||
}
|
||||
$interface_method_storage->referencing_locations[$code_location->file_path][] = $code_location;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($declaring_class_storage->overridden_method_ids[$declaring_method_name])) {
|
||||
$overridden_method_ids = $declaring_class_storage->overridden_method_ids[$declaring_method_name];
|
||||
|
||||
|
@ -183,6 +183,18 @@ class UnusedCodeTest extends TestCase
|
||||
(new A)->foo();
|
||||
(new B)->foo();',
|
||||
],
|
||||
'usedInterfaceMethod' => [
|
||||
'<?php
|
||||
interface I {
|
||||
public function foo() : void;
|
||||
}
|
||||
|
||||
class A implements I {
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
(new A)->foo();',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user