mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 11:02:48 +08:00
优化注释去除
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace app\common\tools\phpparser;
|
namespace app\common\tools\phpparser;
|
||||||
|
|
||||||
use PhpParser\Comment;
|
use PhpParser\Comment;
|
||||||
|
use PhpParser\Comment\Doc;
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Expr\ClassConstFetch;
|
use PhpParser\Node\Expr\ClassConstFetch;
|
||||||
use PhpParser\Node\Expr\Instanceof_;
|
use PhpParser\Node\Expr\Instanceof_;
|
||||||
@@ -53,22 +54,19 @@ class NodeVisitorTools extends NodeVisitorAbstract
|
|||||||
public function leaveNode(Node $node)
|
public function leaveNode(Node $node)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($node instanceof Node) {
|
$comments = $node->getComments();
|
||||||
if (isset($node->attributes['comments'])) {
|
if (!empty($comments)) {
|
||||||
|
$new_comments = [];
|
||||||
$comments = $node->attributes['comments'];
|
foreach ($comments as $comment_item) {
|
||||||
$new_comments = [];
|
if ($comment_item instanceof Doc) {
|
||||||
foreach ($comments as $comment_item) {
|
$new_comments[] = $comment_item;
|
||||||
if ($comment_item instanceof Comment) {
|
|
||||||
} else {
|
|
||||||
$new_comments[] = $comment_item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$node->attributes['comments'] = $new_comments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$node->setAttribute('comments', $new_comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($node instanceof Use_) {
|
if ($node instanceof Use_) {
|
||||||
|
|
||||||
foreach ($node->uses as &$use_item) {
|
foreach ($node->uses as &$use_item) {
|
||||||
|
|||||||
Reference in New Issue
Block a user