mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Fix #1664 - allow templated __get params
This commit is contained in:
parent
758c7e22ff
commit
6ce5fefa4b
@ -479,7 +479,27 @@ class PropertyFetchAnalyzer
|
||||
continue;
|
||||
}
|
||||
|
||||
$stmt->inferredType = Type::getMixed();
|
||||
$fake_method_call = new PhpParser\Node\Expr\MethodCall(
|
||||
$stmt->var,
|
||||
new PhpParser\Node\Identifier('__get', $stmt->name->getAttributes()),
|
||||
[
|
||||
new PhpParser\Node\Arg(
|
||||
new PhpParser\Node\Scalar\String_(
|
||||
$prop_name,
|
||||
$stmt->name->getAttributes()
|
||||
)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
\Psalm\Internal\Analyzer\Statements\Expression\Call\MethodCallAnalyzer::analyze(
|
||||
$statements_analyzer,
|
||||
$fake_method_call,
|
||||
$context
|
||||
);
|
||||
|
||||
$stmt->inferredType = $fake_method_call->inferredType ?? Type::getMixed();
|
||||
|
||||
/*
|
||||
* If we have an explicit list of all allowed magic properties on the class, and we're
|
||||
* not in that list, fall through
|
||||
|
@ -387,6 +387,34 @@ class FileReferenceTest extends TestCase
|
||||
[],
|
||||
[]
|
||||
],
|
||||
'constantRefs' => [
|
||||
'<?php
|
||||
namespace Ns;
|
||||
|
||||
abstract class A {
|
||||
public function foo() : void {}
|
||||
}
|
||||
|
||||
trait T {
|
||||
public function bar(A $a) : void {
|
||||
$a->foo();
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
use T;
|
||||
}',
|
||||
[
|
||||
'ns\a::foo' => [
|
||||
'ns\c::bar' => true,
|
||||
],
|
||||
],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user