Make the Token class abstract.
[htmlpurifier.git] / library / HTMLPurifier / Token.php
blobb1ff93c3bd0d4d3c6ceac363443259165ed2e82b
1 <?php
3 /**
4 * Abstract base token class that all others inherit from.
5 */
6 abstract class HTMLPurifier_Token
8 /**
9 * Line number node was on in source document. Null if unknown.
10 * @type int
12 public $line;
14 /**
15 * Column of line node was on in source document. Null if unknown.
16 * @type int
18 public $col;
20 /**
21 * Lookup array of processing that this token is exempt from.
22 * Currently, valid values are "ValidateAttributes" and
23 * "MakeWellFormed_TagClosedError"
24 * @type array
26 public $armor = array();
28 /**
29 * Used during MakeWellFormed.
30 * @type
32 public $skip;
34 /**
35 * @type
37 public $rewind;
39 /**
40 * @type
42 public $carryover;
44 /**
45 * @param string $n
46 * @return null|string
48 public function __get($n)
50 if ($n === 'type') {
51 trigger_error('Deprecated type property called; use instanceof', E_USER_NOTICE);
52 switch (get_class($this)) {
53 case 'HTMLPurifier_Token_Start':
54 return 'start';
55 case 'HTMLPurifier_Token_Empty':
56 return 'empty';
57 case 'HTMLPurifier_Token_End':
58 return 'end';
59 case 'HTMLPurifier_Token_Text':
60 return 'text';
61 case 'HTMLPurifier_Token_Comment':
62 return 'comment';
63 default:
64 return null;
69 /**
70 * Sets the position of the token in the source document.
71 * @param int $l
72 * @param int $c
74 public function position($l = null, $c = null)
76 $this->line = $l;
77 $this->col = $c;
80 /**
81 * Convenience function for DirectLex settings line/col position.
82 * @param int $l
83 * @param int $c
85 public function rawPosition($l, $c)
87 if ($c === -1) {
88 $l++;
90 $this->line = $l;
91 $this->col = $c;
95 // vim: et sw=4 sts=4