From e2c2d7795c70be95efe25e5dcc923943d72c619d Mon Sep 17 00:00:00 2001 From: robchett Date: Thu, 26 Oct 2023 14:57:48 +0100 Subject: [PATCH] Skip inline docblocks like {@see ...} --- src/Psalm/Internal/Type/ParseTreeCreator.php | 24 +++++++++++++++++--- tests/MethodSignatureTest.php | 9 ++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Type/ParseTreeCreator.php b/src/Psalm/Internal/Type/ParseTreeCreator.php index fcd0c77aeb0..9d11456f978 100644 --- a/src/Psalm/Internal/Type/ParseTreeCreator.php +++ b/src/Psalm/Internal/Type/ParseTreeCreator.php @@ -824,13 +824,31 @@ private function handleValue(array $type_token): void break; case '{': + + ++$this->t; + + $nexter_token = $this->t + 1 < $this->type_token_count ? $this->type_tokens[$this->t + 1] : null; + + if (strpos($nexter_token[0], '@') !== false) { + $this->t = $this->type_token_count; + if ($type_token[0] === '$this') { + $type_token[0] = 'static'; + } + + $new_leaf = new Value( + $type_token[0], + $type_token[1], + $type_token[1] + strlen($type_token[0]), + $type_token[2] ?? null, + $new_parent, + ); + break; + } + $new_leaf = new KeyedArrayTree( $type_token[0], $new_parent, ); - ++$this->t; - - $nexter_token = $this->t + 1 < $this->type_token_count ? $this->type_tokens[$this->t + 1] : null; if ($nexter_token !== null && $nexter_token[0] === '}') { $new_leaf->terminated = true; diff --git a/tests/MethodSignatureTest.php b/tests/MethodSignatureTest.php index f20e73a03e5..e60ddb4c627 100644 --- a/tests/MethodSignatureTest.php +++ b/tests/MethodSignatureTest.php @@ -400,6 +400,15 @@ public static function foo() { '$b' => 'B', ], ], + 'returnIgnoresInlineComments' => [ + 'code' => ' [ 'code' => '