CloningVisitor.php 502 B

1234567891011121314151617181920
  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. {
  12. public function enterNode(Node $origNode) {
  13. $node = clone $origNode;
  14. $node->setAttribute('origNode', $origNode);
  15. return $node;
  16. }
  17. }