From a8c093aea29552d4f34f720efaaab6876b9120ee Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Sun, 11 Feb 2024 02:45:24 +0100 Subject: [PATCH] Handle taking references to unspecified magic methods --- .../Call/StaticMethod/AtomicStaticCallAnalyzer.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php index 0b1b187b8d7..8e187ab391f 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php @@ -517,6 +517,19 @@ private static function handleNamedCall( $codebase->getMethodReturnType($method_id, $fq_class_name), $codebase->methods->getStorage($declaring_method_id)->pure, )]); + } elseif ($codebase->methodExists( + $call_static_method_id = new MethodIdentifier($method_id->fq_class_name, '__callstatic'), + new CodeLocation($statements_analyzer, $stmt), + null, + null, + false, + )) { + $return_type_candidate = new Union([new TClosure( + 'Closure', + null, + $codebase->getMethodReturnType($call_static_method_id, $fq_class_name), + $codebase->methods->getStorage($call_static_method_id)->pure, + )]); } else { if (IssueBuffer::accepts( new UndefinedMethod(