Node.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace PhpParser;
  3. interface Node
  4. {
  5. /**
  6. * Gets the type of the node.
  7. *
  8. * @return string Type of the node
  9. */
  10. public function getType();
  11. /**
  12. * Gets the names of the sub nodes.
  13. *
  14. * @return array Names of sub nodes
  15. */
  16. public function getSubNodeNames();
  17. /**
  18. * Gets line the node started in.
  19. *
  20. * @return int Line
  21. */
  22. public function getLine();
  23. /**
  24. * Sets line the node started in.
  25. *
  26. * @param int $line Line
  27. */
  28. public function setLine($line);
  29. /**
  30. * Gets the doc comment of the node.
  31. *
  32. * The doc comment has to be the last comment associated with the node.
  33. *
  34. * @return null|Comment\Doc Doc comment object or null
  35. */
  36. public function getDocComment();
  37. /**
  38. * Sets the doc comment of the node.
  39. *
  40. * This will either replace an existing doc comment or add it to the comments array.
  41. *
  42. * @param Comment\Doc $docComment Doc comment to set
  43. */
  44. public function setDocComment(Comment\Doc $docComment);
  45. /**
  46. * Sets an attribute on a node.
  47. *
  48. * @param string $key
  49. * @param mixed $value
  50. */
  51. public function setAttribute($key, $value);
  52. /**
  53. * Returns whether an attribute exists.
  54. *
  55. * @param string $key
  56. *
  57. * @return bool
  58. */
  59. public function hasAttribute($key);
  60. /**
  61. * Returns the value of an attribute.
  62. *
  63. * @param string $key
  64. * @param mixed $default
  65. *
  66. * @return mixed
  67. */
  68. public function &getAttribute($key, $default = null);
  69. /**
  70. * Returns all attributes for the given node.
  71. *
  72. * @return array
  73. */
  74. public function getAttributes();
  75. }