diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php index b61e6871d..01878d020 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MethodCallReturnTypeFetcher.php @@ -56,6 +56,7 @@ class MethodCallReturnTypeFetcher $stmt->args, $context, new CodeLocation($statements_analyzer->getSource(), $stmt->name), + $stmt, $lhs_type_part instanceof TGenericObject ? $lhs_type_part->type_params : null ); @@ -76,6 +77,7 @@ class MethodCallReturnTypeFetcher $stmt->args, $context, new CodeLocation($statements_analyzer->getSource(), $stmt->name), + $stmt, $lhs_type_part instanceof TGenericObject ? $lhs_type_part->type_params : null, $fq_class_name, $method_name diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php index d3875d138..85215ce32 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/MissingMethodCallHandler.php @@ -41,7 +41,8 @@ class MissingMethodCallHandler $method_id->method_name, $stmt->args, $context, - new CodeLocation($statements_analyzer->getSource(), $stmt->name) + new CodeLocation($statements_analyzer->getSource(), $stmt->name), + $stmt ); if ($return_type_candidate) { 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 18d26cb7c..67482180a 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php @@ -473,6 +473,7 @@ class AtomicStaticCallAnalyzer $stmt->args, $context, new CodeLocation($statements_analyzer->getSource(), $stmt_name), + $stmt, null, null, strtolower($stmt_name->name) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php index 1bfbfdf05..70b5f9589 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php @@ -193,7 +193,8 @@ class ExistingAtomicStaticCallAnalyzer $stmt_name->name, $stmt->args, $context, - new CodeLocation($statements_analyzer->getSource(), $stmt_name) + new CodeLocation($statements_analyzer->getSource(), $stmt_name), + $stmt ); } @@ -214,6 +215,7 @@ class ExistingAtomicStaticCallAnalyzer $stmt->args, $context, new CodeLocation($statements_analyzer->getSource(), $stmt_name), + $stmt, null, $fq_class_name, $stmt_name->name diff --git a/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php b/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php index 39639b9d8..58c1ced0b 100644 --- a/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/MethodReturnTypeProvider.php @@ -108,7 +108,7 @@ class MethodReturnTypeProvider /** * @param list $call_args * @param ?array $template_type_parameters - * + * @param PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $stmt */ public function getReturnType( StatementsSource $statements_source, @@ -117,6 +117,7 @@ class MethodReturnTypeProvider array $call_args, Context $context, CodeLocation $code_location, + $stmt, ?array $template_type_parameters = null, ?string $called_fq_classlike_name = null, ?string $called_method_name = null @@ -147,6 +148,7 @@ class MethodReturnTypeProvider $call_args, $context, $code_location, + $stmt, $template_type_parameters, $called_fq_classlike_name, $called_method_name ? strtolower($called_method_name) : null diff --git a/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php b/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php index 688117f71..66fcf42cb 100644 --- a/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php +++ b/src/Psalm/Plugin/EventHandler/Event/MethodReturnTypeProviderEvent.php @@ -35,6 +35,10 @@ class MethodReturnTypeProviderEvent * @var CodeLocation */ private $code_location; + /** + * @var PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall + */ + private $stmt; /** * @var Type\Union[]|null */ @@ -54,6 +58,7 @@ class MethodReturnTypeProviderEvent * something should be returned, but can't be more specific. * * @param list $call_args + * @param PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall $stmt * @param ?array $template_type_parameters * @param lowercase-string $method_name_lowercase * @param lowercase-string $called_method_name_lowercase @@ -65,6 +70,7 @@ class MethodReturnTypeProviderEvent array $call_args, Context $context, CodeLocation $code_location, + $stmt, ?array $template_type_parameters = null, ?string $called_fq_classlike_name = null, ?string $called_method_name_lowercase = null @@ -75,6 +81,7 @@ class MethodReturnTypeProviderEvent $this->call_args = $call_args; $this->context = $context; $this->code_location = $code_location; + $this->stmt = $stmt; $this->template_type_parameters = $template_type_parameters; $this->called_fq_classlike_name = $called_fq_classlike_name; $this->called_method_name_lowercase = $called_method_name_lowercase; @@ -136,4 +143,12 @@ class MethodReturnTypeProviderEvent { return $this->called_method_name_lowercase; } + + /** + * @return PhpParser\Node\Expr\MethodCall|PhpParser\Node\Expr\StaticCall + */ + public function getStmt() + { + return $this->stmt; + } }