Token.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Abstract base token class that all others inherit from.
  4. */
  5. class HTMLPurifier_Token {
  6. public $line; /**< Line number node was on in source document. Null if unknown. */
  7. public $col; /**< Column of line node was on in source document. Null if unknown. */
  8. /**
  9. * Lookup array of processing that this token is exempt from.
  10. * Currently, valid values are "ValidateAttributes" and
  11. * "MakeWellFormed_TagClosedError"
  12. */
  13. public $armor = array();
  14. /**
  15. * Used during MakeWellFormed.
  16. */
  17. public $skip;
  18. public $rewind;
  19. public $carryover;
  20. public function __get($n) {
  21. if ($n === 'type') {
  22. trigger_error('Deprecated type property called; use instanceof', E_USER_NOTICE);
  23. switch (get_class($this)) {
  24. case 'HTMLPurifier_Token_Start': return 'start';
  25. case 'HTMLPurifier_Token_Empty': return 'empty';
  26. case 'HTMLPurifier_Token_End': return 'end';
  27. case 'HTMLPurifier_Token_Text': return 'text';
  28. case 'HTMLPurifier_Token_Comment': return 'comment';
  29. default: return null;
  30. }
  31. }
  32. }
  33. /**
  34. * Sets the position of the token in the source document.
  35. */
  36. public function position($l = null, $c = null) {
  37. $this->line = $l;
  38. $this->col = $c;
  39. }
  40. /**
  41. * Convenience function for DirectLex settings line/col position.
  42. */
  43. public function rawPosition($l, $c) {
  44. if ($c === -1) $l++;
  45. $this->line = $l;
  46. $this->col = $c;
  47. }
  48. }
  49. // vim: et sw=4 sts=4