From e30807b64cabd2e39ef6fbd65cc7994edb36e9dc Mon Sep 17 00:00:00 2001 From: auooru Date: Thu, 2 Nov 2023 11:45:14 +0800 Subject: [PATCH] update: csfix --- src/Visitor/AttributeRewriteVisitor.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Visitor/AttributeRewriteVisitor.php b/src/Visitor/AttributeRewriteVisitor.php index 44f9879..e38626f 100644 --- a/src/Visitor/AttributeRewriteVisitor.php +++ b/src/Visitor/AttributeRewriteVisitor.php @@ -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, }; @@ -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(); }