1
0
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:
Matthew Brown 2017-12-29 19:38:01 -05:00
parent 875bb8c072
commit 086b314df8
2 changed files with 23 additions and 0 deletions

View File

@ -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];

View File

@ -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();',
],
];
}