Skip to content

Commit

Permalink
[CodeQuality] Using local variable $hasChanged on NarrowUnionTypeDocR…
Browse files Browse the repository at this point in the history
…ector (#3697)
  • Loading branch information
samsonasik committed Apr 28, 2023
1 parent 3cf8e88 commit 14b6073
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*/
final class NarrowUnionTypeDocRector extends AbstractRector
{
private bool $hasChanged = false;

public function __construct(
private readonly UnionTypeAnalyzer $unionTypeAnalyzer
) {
Expand Down Expand Up @@ -72,7 +70,7 @@ public function refactor(Node $node): ?Node
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$params = $node->getParams();

$this->hasChanged = false;
$hasChanged = false;

foreach ($params as $key => $param) {
/** @var string $paramName */
Expand All @@ -85,17 +83,17 @@ public function refactor(Node $node): ?Node

if ($this->unionTypeAnalyzer->isScalar($paramType)) {
$this->changeDocObjectScalar($key, $phpDocInfo);
$this->hasChanged = true;
$hasChanged = true;
continue;
}

if ($this->unionTypeAnalyzer->hasObjectWithoutClassType($paramType)) {
$this->changeDocObjectWithoutClassType($paramType, $key, $phpDocInfo);
$this->hasChanged = true;
$hasChanged = true;
}
}

if ($this->hasChanged) {
if ($hasChanged) {
return $node;
}

Expand Down

0 comments on commit 14b6073

Please sign in to comment.