Skip to content

Commit

Permalink
ensure pointed to target key (#5278)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 23, 2023
1 parent 944d5fb commit 26f3570
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,20 +269,20 @@ private function processDescriptionAsSpacelessPhpDoctagNode(
return $key;
}

$unsetKey = $phpDocNode->children[$key] instanceof SpacelessPhpDocTagNode
? $key + count($spacelessPhpDocTagNodes)
: $key;
while (isset($phpDocNode->children[$key]) && $phpDocNode->children[$key] !== $phpDocTagNode) {
++$key;
}

unset($phpDocNode->children[$unsetKey]);
unset($phpDocNode->children[$key]);

$classNode = new PhpDocTagNode($phpDocTagNode->name, $phpDocTagNode->value);
$description = Strings::replace($description, self::LONG_ANNOTATION_REGEX, '');
$description = substr($description, 0, -7);

$phpDocTagNode->value->description = $description;
$phpDocNode->children[$unsetKey] = $classNode;
$phpDocNode->children[$key] = $classNode;

array_splice($phpDocNode->children, $unsetKey + 1, 0, $spacelessPhpDocTagNodes);
array_splice($phpDocNode->children, $key + 1, 0, $spacelessPhpDocTagNodes);

return $key + count($spacelessPhpDocTagNodes);
}
Expand Down

0 comments on commit 26f3570

Please sign in to comment.