CloningVisitor.php 502 B

12345678910111213141516171819
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\NodeVisitor;
  3. use PhpParser\Node;
  4. use PhpParser\NodeVisitorAbstract;
  5. /**
  6. * Visitor cloning all nodes and linking to the original nodes using an attribute.
  7. *
  8. * This visitor is required to perform format-preserving pretty prints.
  9. */
  10. class CloningVisitor extends NodeVisitorAbstract {
  11. public function enterNode(Node $origNode) {
  12. $node = clone $origNode;
  13. $node->setAttribute('origNode', $origNode);
  14. return $node;
  15. }
  16. }