Skip to content

Commit

Permalink
Merge pull request #7013 from orklah/6951
Browse files Browse the repository at this point in the history
Allow overriding the signature type by a param docblock for promoted properties
  • Loading branch information
orklah committed Nov 28, 2021
2 parents 1af805e + a6e4230 commit 8bc71fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Expand Up @@ -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;
}

Expand Down
16 changes: 16 additions & 0 deletions tests/AnnotationTest.php
Expand Up @@ -1955,8 +1955,24 @@ public function __construct(
',
'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',
],
];
}
}

0 comments on commit 8bc71fc

Please sign in to comment.