Skip to content

Commit baf3fdb

Browse files
authored
Merge pull request #7675 from samsonasik/rector-refactor-under
[Rector] Refactor UnderscoreToCamelCaseVariableNameRector as removed findParentByType()
2 parents 1a83ef4 + 47990ba commit baf3fdb

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

utils/Rector/UnderscoreToCamelCaseVariableNameRector.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,16 @@ public function refactor(Node $node): ?Node
113113

114114
private function updateDocblock(Variable $variable, string $variableName, string $camelCaseName): void
115115
{
116-
$parentClassMethodOrFunction = $this->betterNodeFinder->findParentByTypes($variable, [ClassMethod::class, Function_::class]);
116+
$parentFunctionLike = $this->betterNodeFinder->findParentType($variable, ClassMethod::class);
117117

118-
if ($parentClassMethodOrFunction === null) {
119-
return;
118+
if ($parentFunctionLike === null) {
119+
$parentFunctionLike = $this->betterNodeFinder->findParentType($variable, Function_::class);
120+
if ($parentFunctionLike === null) {
121+
return;
122+
}
120123
}
121124

122-
$docComment = $parentClassMethodOrFunction->getDocComment();
125+
$docComment = $parentFunctionLike->getDocComment();
123126
if ($docComment === null) {
124127
return;
125128
}
@@ -133,7 +136,7 @@ private function updateDocblock(Variable $variable, string $variableName, string
133136
return;
134137
}
135138

136-
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($parentClassMethodOrFunction);
139+
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($parentFunctionLike);
137140
$paramTagValueNodes = $phpDocInfo->getParamTagValueNodes();
138141

139142
foreach ($paramTagValueNodes as $paramTagValueNode) {
@@ -143,6 +146,6 @@ private function updateDocblock(Variable $variable, string $variableName, string
143146
}
144147
}
145148

146-
$parentClassMethodOrFunction->setDocComment(new Doc($phpDocInfo->getPhpDocNode()->__toString()));
149+
$parentFunctionLike->setDocComment(new Doc($phpDocInfo->getPhpDocNode()->__toString()));
147150
}
148151
}

0 commit comments

Comments
 (0)