Skip to content

Commit

Permalink
[BetterPhpDocParser] Merge PhpDocInfo::getParamTagValueByName() with …
Browse files Browse the repository at this point in the history
…getParamTagValueNodeByName() (#2703)

* [BetterPhpDocParser] Merge PhpDocInfo::getParamTagValueByName() with getParamTagValueNodeByName()

* [BetterPhpDocParser] Merge PhpDocInfo::getParamTagValueByName() with getParamTagValueNodeByName()
  • Loading branch information
samsonasik committed Jul 23, 2022
1 parent c4d6f19 commit cdf7bf5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
13 changes: 0 additions & 13 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,6 @@ public function getParamTagValueNodes(): array
return $this->phpDocNode->getParamTagValues();
}

public function getParamTagValueNodeByName(string $parameterName): ?ParamTagValueNode
{
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
continue;
}

return $paramTagValueNode;
}

return null;
}

public function getVarType(string $tagName = '@var'): Type
{
return $this->getTypeOrMixed($this->getVarTagValueNode($tagName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function renameParameterNameInDocBlock(ParamRename $paramRename): void
$functionLike = $paramRename->getFunctionLike();

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($paramRename->getCurrentName());
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramRename->getCurrentName());
if (! $paramTagValueNode instanceof ParamTagValueNode) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion rules/Naming/PropertyRenamer/PropertyPromotionRenamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private function renameParamDoc(
string $paramVarName,
string $desiredPropertyName
): void {
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($paramVarName);
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramVarName);
if (! $paramTagValueNode instanceof ParamTagValueNode) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function refactor(Node $node): ?Node
$oldName = $this->getName($param->var);
$this->variableRenamer->renameVariableInFunctionLike($constructClassMethod, $oldName, $propertyName, null);

$paramTagValueNode = $classMethodPhpDocInfo->getParamTagValueNodeByName($paramName);
$paramTagValueNode = $classMethodPhpDocInfo->getParamTagValueByName($paramName);

if (! $paramTagValueNode instanceof ParamTagValueNode) {
$this->decorateParamWithPropertyPhpDocInfo($constructClassMethod, $property, $param, $paramName);
Expand Down

0 comments on commit cdf7bf5

Please sign in to comment.