From a6e4230d2d928c0af1660a252bb5d0f543d224b2 Mon Sep 17 00:00:00 2001 From: orklah Date: Sun, 28 Nov 2021 11:10:55 +0100 Subject: [PATCH] Allow overriding the signature type by a param docblock for promoted properties --- .../Reflector/FunctionLikeNodeScanner.php | 2 +- tests/AnnotationTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php index 4d85c3c8413..ec081db6f22 100644 --- a/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php +++ b/src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeNodeScanner.php @@ -618,7 +618,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal } //no docblock type was provided for param but we have one for property - if ($param_storage->type === null && $var_comment_type) { + if ($var_comment_type) { $param_storage->type = $var_comment_type; } diff --git a/tests/AnnotationTest.php b/tests/AnnotationTest.php index 0fee6db51a6..908de6f4dd1 100644 --- a/tests/AnnotationTest.php +++ b/tests/AnnotationTest.php @@ -1955,8 +1955,24 @@ public function __construct( ', 'error_message' => 'InvalidDocblock', ], + 'promotedPropertyWithParamDocblockAndSignatureType' => [ + 'licenseType = "dudidu"; + echo $a->licenseType;', + 'error_message' => 'InvalidArgument', + ], ]; } }