mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix get magic property checks
This commit is contained in:
parent
37659445f0
commit
b7a7e2fb87
@ -529,6 +529,8 @@ class AtomicPropertyFetchAnalyzer
|
||||
|
||||
$statements_analyzer->node_data = clone $statements_analyzer->node_data;
|
||||
|
||||
$statements_analyzer->node_data->setType($stmt->var, new Type\Union([$lhs_type_part]));
|
||||
|
||||
$fake_method_call = new PhpParser\Node\Expr\MethodCall(
|
||||
$stmt->var,
|
||||
new PhpParser\Node\Identifier('__get', $stmt->name->getAttributes()),
|
||||
@ -544,10 +546,6 @@ class AtomicPropertyFetchAnalyzer
|
||||
|
||||
$suppressed_issues = $statements_analyzer->getSuppressedIssues();
|
||||
|
||||
if (!in_array('PossiblyNullReference', $suppressed_issues, true)) {
|
||||
$statements_analyzer->addSuppressedIssues(['PossiblyNullReference']);
|
||||
}
|
||||
|
||||
if (!in_array('InternalMethod', $suppressed_issues, true)) {
|
||||
$statements_analyzer->addSuppressedIssues(['InternalMethod']);
|
||||
}
|
||||
@ -559,10 +557,6 @@ class AtomicPropertyFetchAnalyzer
|
||||
false
|
||||
);
|
||||
|
||||
if (!in_array('PossiblyNullReference', $suppressed_issues, true)) {
|
||||
$statements_analyzer->removeSuppressedIssues(['PossiblyNullReference']);
|
||||
}
|
||||
|
||||
if (!in_array('InternalMethod', $suppressed_issues, true)) {
|
||||
$statements_analyzer->removeSuppressedIssues(['InternalMethod']);
|
||||
}
|
||||
|
@ -2334,6 +2334,25 @@ class PropertyTypeTest extends TestCase
|
||||
}
|
||||
}'
|
||||
],
|
||||
'ignoreUndefinedMethodOnUnion' => [
|
||||
'<?php
|
||||
class NullObject {
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function __get(string $s) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class User {
|
||||
public string $name = "Dave";
|
||||
}
|
||||
|
||||
function takesNullableUser(User|NullObject $user) : void {
|
||||
echo $user->name;
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user