Skip to content

Commit 806b032

Browse files
committed
Downgrade UndefinedMethod to PossiblyUndefinedMethod issue when one type has __call defined
1 parent 5f03d08 commit 806b032

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/Psalm/Checker/Statements/Expression/Call/MethodCallChecker.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ public static function analyze(
267267
$statements_checker->getSource()
268268
)
269269
) {
270+
$has_valid_method_call_type = true;
271+
$existent_method_ids[] = $method_id;
270272
$return_type = Type::getMixed();
271273
continue;
272274
}

tests/MethodCallTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ public function __call(string $method_name) {}
9191
$a = new A;
9292
$a->bar();',
9393
],
94+
'canBeCalledOnMagic' => [
95+
'<?php
96+
class A {
97+
public function __call(string $method) {}
98+
}
99+
100+
class B {}
101+
102+
$a = rand(0, 1) ? new A : new B;
103+
104+
$a->maybeUndefinedMethod();',
105+
'assertions' => [],
106+
'error_levels' => ['PossiblyUndefinedMethod'],
107+
],
94108
];
95109
}
96110

0 commit comments

Comments
 (0)