Skip to content

Commit

Permalink
update: csfix
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Nov 2, 2023
1 parent 29670d6 commit e30807b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Visitor/AttributeRewriteVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function leaveNode(Node $node): ?Node

return match (true)
{
$node instanceof Node\Stmt\ClassLike => $this->generateClass(/* @var $node Node\Stmt\ClassLike */ $node),
$node instanceof Node\Stmt\ClassLike => $this->generateClass(/* @var $node Node\Stmt\ClassLike */ $node),
$node instanceof Node\Stmt\ClassMethod => $this->generateClassMethodAttributes(/* @var $node Node\Stmt\ClassMethod */ $node),
default => null,
};
Expand All @@ -175,24 +175,32 @@ private function generateClass(Node\Stmt\ClassLike $node): ?Node\Stmt\ClassLike
}

$newStmts = [];
foreach ($node->stmts as $stmt) {
if ($stmt instanceof Node\Stmt\Property) {
foreach ($node->stmts as $stmt)
{
if ($stmt instanceof Node\Stmt\Property)
{
$newProps = [];
foreach ($stmt->props as $prop) {
if ($prop instanceof Node\Stmt\PropertyProperty && 'defaultFieldName' === $prop->name->toString()) {
foreach ($stmt->props as $prop)
{
if ($prop instanceof Node\Stmt\PropertyProperty && 'defaultFieldName' === $prop->name->toString())
{
$this->handleCode->setModified();
continue;
}
$newProps[] = $prop;
}
if ($newProps) {
if ($newProps)
{
$newStmts[] = $newProps;
}
} else {
}
else
{
$newStmts[] = $stmt;
}
}
if ($this->handleCode->isModified()) {
if ($this->handleCode->isModified())
{
$node->stmts = $newStmts;
$this->handleCode->setModified();
}
Expand Down

0 comments on commit e30807b

Please sign in to comment.