From 18a47529705e71681371b7f0d6eaa1931a8bfd08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sat, 12 Aug 2023 12:28:23 +0200 Subject: [PATCH 1/2] Add test --- tests/MethodCallTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/MethodCallTest.php b/tests/MethodCallTest.php index f6cb3e75099..1f00196809e 100644 --- a/tests/MethodCallTest.php +++ b/tests/MethodCallTest.php @@ -1203,6 +1203,17 @@ public function method(mixed $value): mixed 'ignored_issues' => [], 'php_version' => '8.0', ], + 'phpdocObjectTypeAndReferenceInParameter' => [ + 'code' => 'bar($x);', + ], ]; } From 35183b9542b82d46f7e0d53629677220aafe27d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sat, 12 Aug 2023 12:50:24 +0200 Subject: [PATCH 2/2] Add fix --- .../Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php index 4773c21b650..437f65d7510 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/MethodCallAnalyzer.php @@ -29,6 +29,7 @@ use Psalm\IssueBuffer; use Psalm\Type; use Psalm\Type\Atomic\TNamedObject; +use Psalm\Type\Atomic\TObject; use Psalm\Type\Atomic\TTemplateParam; use Psalm\Type\Union; @@ -412,7 +413,7 @@ public static function analyze( $types = $class_type->getAtomicTypes(); foreach ($types as $key => &$type) { - if (!$type instanceof TNamedObject) { + if (!$type instanceof TNamedObject && !$type instanceof TObject) { unset($types[$key]); } else { $type = $type->setFromDocblock(false);