Skip to content

Commit

Permalink
[Php80] Remove parent attribute usage on ClassPropertyAssignToConstru…
Browse files Browse the repository at this point in the history
…ctorPromotionRector (#4022)
  • Loading branch information
samsonasik committed May 29, 2023
1 parent 5979f30 commit b97fe19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function isAllowed(TypeNode $typeNode): bool
return in_array((string) $typeNode, self::ALLOWED_IDENTIFIER_TYPENODE_TYPES, true);
}

public function copyPropertyDocToParam(Property $property, Param $param): void
public function copyPropertyDocToParam(ClassMethod $classMethod, Property $property, Param $param): void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($property);
if (! $phpDocInfo instanceof PhpDocInfo) {
Expand All @@ -222,13 +222,7 @@ public function copyPropertyDocToParam(Property $property, Param $param): void
return;
}

$parentNode = $param->getAttribute(AttributeKey::PARENT_NODE);
$paramVarName = $this->nodeNameResolver->getName($param->var);

if (! $parentNode instanceof ClassMethod) {
return;
}

if (! $this->isAllowed($varTagValueNode->type)) {
return;
}
Expand All @@ -240,7 +234,7 @@ public function copyPropertyDocToParam(Property $property, Param $param): void
$phpDocInfo->removeByType(VarTagValueNode::class);
$param->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);

$phpDocInfo = $parentNode->getAttribute(AttributeKey::PHP_DOC_INFO);
$phpDocInfo = $classMethod->getAttribute(AttributeKey::PHP_DOC_INFO);
$paramType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($varTagValueNode, $property);

$this->changeParamType($phpDocInfo, $paramType, $param, $paramVarName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function refactor(Node $node): ?Node
$param->attrGroups = array_merge($param->attrGroups, $property->attrGroups);
$this->processNullableType($property, $param);

$this->phpDocTypeChanger->copyPropertyDocToParam($property, $param);
$this->phpDocTypeChanger->copyPropertyDocToParam($constructClassMethod, $property, $param);
}

return $node;
Expand Down

0 comments on commit b97fe19

Please sign in to comment.