NodeVisitor.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. interface PHPParser_NodeVisitor
  3. {
  4. /**
  5. * Called once before traversal.
  6. *
  7. * Return value semantics:
  8. * * null: $nodes stays as-is
  9. * * otherwise: $nodes is set to the return value
  10. *
  11. * @param PHPParser_Node[] $nodes Array of nodes
  12. *
  13. * @return null|PHPParser_Node[] Array of nodes
  14. */
  15. public function beforeTraverse(array $nodes);
  16. /**
  17. * Called when entering a node.
  18. *
  19. * Return value semantics:
  20. * * null: $node stays as-is
  21. * * otherwise: $node is set to the return value
  22. *
  23. * @param PHPParser_Node $node Node
  24. *
  25. * @return null|PHPParser_Node Node
  26. */
  27. public function enterNode(PHPParser_Node $node);
  28. /**
  29. * Called when leaving a node.
  30. *
  31. * Return value semantics:
  32. * * null: $node stays as-is
  33. * * false: $node is removed from the parent array
  34. * * array: The return value is merged into the parent array (at the position of the $node)
  35. * * otherwise: $node is set to the return value
  36. *
  37. * @param PHPParser_Node $node Node
  38. *
  39. * @return null|PHPParser_Node|false|PHPParser_Node[] Node
  40. */
  41. public function leaveNode(PHPParser_Node $node);
  42. /**
  43. * Called once after traversal.
  44. *
  45. * Return value semantics:
  46. * * null: $nodes stays as-is
  47. * * otherwise: $nodes is set to the return value
  48. *
  49. * @param PHPParser_Node[] $nodes Array of nodes
  50. *
  51. * @return null|PHPParser_Node[] Array of nodes
  52. */
  53. public function afterTraverse(array $nodes);
  54. }