AbstractNodeVisitor.php 920 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace ClassPreloader\Parser;
  3. /**
  4. * Abstract node visitor used to track the filename
  5. */
  6. abstract class AbstractNodeVisitor extends \PHPParser_NodeVisitorAbstract
  7. {
  8. /**
  9. * @var string Current file being parsed
  10. */
  11. protected $filename = '';
  12. /**
  13. * Set the full path to the current file being parsed
  14. *
  15. * @param string $filename Filename being parser
  16. *
  17. * @return self
  18. */
  19. public function setFilename($filename)
  20. {
  21. $this->filename = $filename;
  22. return $this;
  23. }
  24. /**
  25. * Get the full path to the current file being parsed
  26. *
  27. * @return string
  28. */
  29. public function getFilename()
  30. {
  31. return $this->filename;
  32. }
  33. /**
  34. * Get the directory of the current file being parsed
  35. *
  36. * @return string
  37. */
  38. public function getDir()
  39. {
  40. return dirname($this->getFilename());
  41. }
  42. }