Skip to content

Commit

Permalink
Merge pull request #6872 from orklah/InvalidDocblockPromotedProperties
Browse files Browse the repository at this point in the history
allow signature type for promoted property as well as property docblock
  • Loading branch information
orklah committed Nov 9, 2021
2 parents 0fbf515 + d409c06 commit 830c898
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal
}

//both way to document type were used
if ($param_storage->type && $var_comment_type) {
if ($param_storage->type && $param_storage->type->from_docblock && $var_comment_type) {
if (IssueBuffer::accepts(
new InvalidDocblock(
'Param ' . $param_storage->name . ' of ' . $cased_function_id .
Expand All @@ -625,7 +625,7 @@ public function start(PhpParser\Node\FunctionLike $stmt, bool $fake_method = fal

$property_storage = $classlike_storage->properties[$param_storage->name] = new PropertyStorage();
$property_storage->is_static = false;
$property_storage->type = $param_storage->type ?? $var_comment_type;
$property_storage->type = $param_storage->type;
$property_storage->signature_type = $param_storage->signature_type;
$property_storage->signature_type_location = $param_storage->signature_type_location;
$property_storage->type_location = $param_storage->type_location;
Expand Down
13 changes: 13 additions & 0 deletions tests/AnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,19 @@ public function __construct(
new UserRole(new stdClass(), new stdClass());
'
],
'promotedPropertiesDocumentationForPropertyAndSignature' => [
'<?php
final class A
{
public function __construct(
/**
* @var iterable<string>
*/
private iterable $strings,
) {
}
}'
],
];
}

Expand Down

0 comments on commit 830c898

Please sign in to comment.