1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Allow overriding the signature type by a param docblock for promoted properties

This commit is contained in:
orklah 2021-11-28 11:10:55 +01:00
parent b42c2814a9
commit a6e4230d2d
2 changed files with 17 additions and 1 deletions

View File

@ -618,7 +618,7 @@ class FunctionLikeNodeScanner
}
//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;
}

View File

@ -1955,8 +1955,24 @@ class AnnotationTest extends TestCase
',
'error_message' => 'InvalidDocblock',
],
'promotedPropertyWithParamDocblockAndSignatureType' => [
'<?php
class A
{
public function __construct(
/** @var "cti"|"basic"|"teams"|"" */
public string $licenseType = "",
) {
}
}
$a = new A("ladida");
$a->licenseType = "dudidu";
echo $a->licenseType;',
'error_message' => 'InvalidArgument',
],
];
}
}