mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix issue with nested trait methods
This commit is contained in:
parent
49c4dd8a5d
commit
ccbe9980f5
@ -292,8 +292,16 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
|
||||
} elseif ($classlike_source instanceof \Psalm\Checker\TraitChecker
|
||||
&& $codebase->methodExists($classlike_source_fqcln . '::' . $method_name_lc)
|
||||
) {
|
||||
$method_id = $classlike_source_fqcln . '::' . $method_name_lc;
|
||||
$fq_class_name = $classlike_source_fqcln;
|
||||
$declaring_method_id = (string) $codebase->methods->getDeclaringMethodId(
|
||||
$classlike_source_fqcln . '::' . $method_name_lc
|
||||
);
|
||||
|
||||
list($declaring_class) = explode('::', $declaring_method_id);
|
||||
|
||||
if ($declaring_class === $classlike_source_fqcln) {
|
||||
$method_id = $classlike_source_fqcln . '::' . $method_name_lc;
|
||||
$fq_class_name = $classlike_source_fqcln;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,6 +498,30 @@ class TraitTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'aliasedPrivateMethodInternalCallWithLocalDefinition' => [
|
||||
'<?php
|
||||
trait T1 {
|
||||
use T2;
|
||||
|
||||
private function foo() : int {
|
||||
return $this->bar();
|
||||
}
|
||||
}
|
||||
|
||||
trait T2 {
|
||||
private function bar() : int {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
use T1;
|
||||
|
||||
private function baz() : int {
|
||||
return $this->bar();
|
||||
}
|
||||
}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user