?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/Comments.tar
???????
CommentRemover.php 0000644 00000001615 15127644443 0010234 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Comments; use PhpParser\Node; use Rector\Comments\NodeTraverser\CommentRemovingNodeTraverser; /** * @see \Rector\Tests\Comments\CommentRemover\CommentRemoverTest */ final class CommentRemover { /** * @readonly * @var \Rector\Comments\NodeTraverser\CommentRemovingNodeTraverser */ private $commentRemovingNodeTraverser; public function __construct(CommentRemovingNodeTraverser $commentRemovingNodeTraverser) { $this->commentRemovingNodeTraverser = $commentRemovingNodeTraverser; } /** * @param Node[]|Node|null $node * @return Node[]|null */ public function removeFromNode($node) : ?array { if ($node === null) { return null; } $nodes = \is_array($node) ? $node : [$node]; return $this->commentRemovingNodeTraverser->traverse($nodes); } } NodeVisitor/CommentRemovingNodeVisitor.php 0000644 00000001111 15127644443 0015025 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Comments\NodeVisitor; use PhpParser\Node; use PhpParser\NodeVisitorAbstract; use Rector\NodeTypeResolver\Node\AttributeKey; final class CommentRemovingNodeVisitor extends NodeVisitorAbstract { public function enterNode(Node $node) : Node { // the node must be cloned, so original node is not touched in final print $clonedNode = clone $node; $clonedNode->setAttribute(AttributeKey::COMMENTS, []); $clonedNode->setAttribute(AttributeKey::PHP_DOC_INFO, null); return $clonedNode; } } NodeTraverser/CommentRemovingNodeTraverser.php 0000644 00000000642 15127644443 0015671 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Comments\NodeTraverser; use PhpParser\NodeTraverser; use Rector\Comments\NodeVisitor\CommentRemovingNodeVisitor; final class CommentRemovingNodeTraverser extends NodeTraverser { public function __construct(CommentRemovingNodeVisitor $commentRemovingNodeVisitor) { $this->addVisitor($commentRemovingNodeVisitor); parent::__construct(); } } NodeDocBlock/DocBlockUpdater.php 0000644 00000003337 15127644443 0012570 0 ustar 00 <?php declare (strict_types=1); namespace Rector\Comments\NodeDocBlock; use PhpParser\Comment; use PhpParser\Comment\Doc; use PhpParser\Node; use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo; use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter; use Rector\NodeTypeResolver\Node\AttributeKey; final class DocBlockUpdater { /** * @readonly * @var \Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter */ private $phpDocInfoPrinter; public function __construct(PhpDocInfoPrinter $phpDocInfoPrinter) { $this->phpDocInfoPrinter = $phpDocInfoPrinter; } public function updateRefactoredNodeWithPhpDocInfo(Node $node) : void { // nothing to change? don't save it $phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO); if (!$phpDocInfo instanceof PhpDocInfo) { return; } $phpDocNode = $phpDocInfo->getPhpDocNode(); if ($phpDocNode->children === []) { $this->setCommentsAttribute($node); return; } $printedPhpDoc = $this->printPhpDocInfoToString($phpDocInfo); $node->setDocComment(new Doc($printedPhpDoc)); } private function setCommentsAttribute(Node $node) : void { $comments = \array_filter($node->getComments(), static function (Comment $comment) : bool { return !$comment instanceof Doc; }); $node->setAttribute(AttributeKey::COMMENTS, $comments); } private function printPhpDocInfoToString(PhpDocInfo $phpDocInfo) : string { if ($phpDocInfo->isNewNode()) { return $this->phpDocInfoPrinter->printNew($phpDocInfo); } return $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo); } }
| ver. 1.6 |
Github
|
.
| PHP 8.2.30 | ??????????? ?????????: 0 |
proxy
|
phpinfo
|
???????????