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

Merge pull request #7013 from orklah/6951

Allow overriding the signature type by a param docblock for promoted properties
This commit is contained in:
orklah 2021-11-28 11:50:43 +01:00 committed by GitHub
commit 8bc71fcf85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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',
],
];
}
}