@@ -4,13 +4,13 @@ |
||
4 | 4 | |
5 | 5 | class Text extends Node |
6 | 6 | { |
7 | - public $isText = true; |
|
8 | - public $value = ''; |
|
7 | + public $isText = true; |
|
8 | + public $value = ''; |
|
9 | 9 | |
10 | - public function __construct($line) |
|
11 | - { |
|
12 | - if (is_string($line)) { |
|
13 | - $this->value = $line; |
|
14 | - } |
|
15 | - } |
|
10 | + public function __construct($line) |
|
11 | + { |
|
12 | + if (is_string($line)) { |
|
13 | + $this->value = $line; |
|
14 | + } |
|
15 | + } |
|
16 | 16 | } |
@@ -4,10 +4,10 @@ |
||
4 | 4 | |
5 | 5 | class Doctype extends Node |
6 | 6 | { |
7 | - public $value; |
|
7 | + public $value; |
|
8 | 8 | |
9 | - public function __construct($value) |
|
10 | - { |
|
11 | - $this->value = $value; |
|
12 | - } |
|
9 | + public function __construct($value) |
|
10 | + { |
|
11 | + $this->value = $value; |
|
12 | + } |
|
13 | 13 | } |
@@ -4,18 +4,18 @@ |
||
4 | 4 | |
5 | 5 | abstract class Node |
6 | 6 | { |
7 | - public function isInline() |
|
8 | - { |
|
9 | - if (isset($this->isBlock) && $this->isBlock) { |
|
10 | - foreach ($this->nodes as $node) { |
|
11 | - if (!$node->isInline()) { |
|
12 | - return false; |
|
13 | - } |
|
14 | - } |
|
7 | + public function isInline() |
|
8 | + { |
|
9 | + if (isset($this->isBlock) && $this->isBlock) { |
|
10 | + foreach ($this->nodes as $node) { |
|
11 | + if (!$node->isInline()) { |
|
12 | + return false; |
|
13 | + } |
|
14 | + } |
|
15 | 15 | |
16 | - return true; |
|
17 | - } |
|
16 | + return true; |
|
17 | + } |
|
18 | 18 | |
19 | - return isset($this->isText) && $this->isText; |
|
20 | - } |
|
19 | + return isset($this->isText) && $this->isText; |
|
20 | + } |
|
21 | 21 | } |
@@ -4,23 +4,23 @@ |
||
4 | 4 | |
5 | 5 | class Filter extends Node |
6 | 6 | { |
7 | - public $name; |
|
8 | - public $block; |
|
9 | - public $attributes; |
|
10 | - public $isASTFilter; |
|
7 | + public $name; |
|
8 | + public $block; |
|
9 | + public $attributes; |
|
10 | + public $isASTFilter; |
|
11 | 11 | |
12 | - public function __construct($name, $block, $attributes) |
|
13 | - { |
|
14 | - $this->name = $name; |
|
15 | - $this->block = $block; |
|
16 | - $this->attributes = $attributes; |
|
12 | + public function __construct($name, $block, $attributes) |
|
13 | + { |
|
14 | + $this->name = $name; |
|
15 | + $this->block = $block; |
|
16 | + $this->attributes = $attributes; |
|
17 | 17 | |
18 | - $this->isASTFilter = false; |
|
19 | - foreach ($block->nodes as $node) { |
|
20 | - if (!isset($node->isText) || !$node->isText) { |
|
21 | - $this->isASTFilter = true; |
|
22 | - break; |
|
23 | - } |
|
24 | - } |
|
25 | - } |
|
18 | + $this->isASTFilter = false; |
|
19 | + foreach ($block->nodes as $node) { |
|
20 | + if (!isset($node->isText) || !$node->isText) { |
|
21 | + $this->isASTFilter = true; |
|
22 | + break; |
|
23 | + } |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -7,48 +7,48 @@ |
||
7 | 7 | */ |
8 | 8 | class Attributes extends Node |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - public $attributes = array(); |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + public $attributes = array(); |
|
14 | 14 | |
15 | - /** |
|
16 | - * @param $name |
|
17 | - * @param $value |
|
18 | - * @param bool $escaped |
|
19 | - * |
|
20 | - * @return $this |
|
21 | - */ |
|
22 | - public function setAttribute($name, $value, $escaped = false) |
|
23 | - { |
|
24 | - $this->attributes[] = compact('name', 'value', 'escaped'); |
|
15 | + /** |
|
16 | + * @param $name |
|
17 | + * @param $value |
|
18 | + * @param bool $escaped |
|
19 | + * |
|
20 | + * @return $this |
|
21 | + */ |
|
22 | + public function setAttribute($name, $value, $escaped = false) |
|
23 | + { |
|
24 | + $this->attributes[] = compact('name', 'value', 'escaped'); |
|
25 | 25 | |
26 | - return $this; |
|
27 | - } |
|
26 | + return $this; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param $name |
|
31 | - */ |
|
32 | - public function removeAttribute($name) |
|
33 | - { |
|
34 | - foreach ($this->attributes as $k => $attr) { |
|
35 | - if ($attr['name'] === $name) { |
|
36 | - unset($this->attributes[$k]); |
|
37 | - } |
|
38 | - } |
|
39 | - } |
|
29 | + /** |
|
30 | + * @param $name |
|
31 | + */ |
|
32 | + public function removeAttribute($name) |
|
33 | + { |
|
34 | + foreach ($this->attributes as $k => $attr) { |
|
35 | + if ($attr['name'] === $name) { |
|
36 | + unset($this->attributes[$k]); |
|
37 | + } |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param $name |
|
43 | - * |
|
44 | - * @return mixed |
|
45 | - */ |
|
46 | - public function getAttribute($name) |
|
47 | - { |
|
48 | - foreach ($this->attributes as $attr) { |
|
49 | - if ($attr['name'] === $name) { |
|
50 | - return $attr; |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
41 | + /** |
|
42 | + * @param $name |
|
43 | + * |
|
44 | + * @return mixed |
|
45 | + */ |
|
46 | + public function getAttribute($name) |
|
47 | + { |
|
48 | + foreach ($this->attributes as $attr) { |
|
49 | + if ($attr['name'] === $name) { |
|
50 | + return $attr; |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | } |
@@ -4,86 +4,86 @@ |
||
4 | 4 | |
5 | 5 | class Tag extends Attributes |
6 | 6 | { |
7 | - protected static $inlineTags = array( |
|
8 | - 'a', |
|
9 | - 'abbr', |
|
10 | - 'acronym', |
|
11 | - 'b', |
|
12 | - 'br', |
|
13 | - 'code', |
|
14 | - 'em', |
|
15 | - 'font', |
|
16 | - 'i', |
|
17 | - 'img', |
|
18 | - 'ins', |
|
19 | - 'kbd', |
|
20 | - 'map', |
|
21 | - 'samp', |
|
22 | - 'small', |
|
23 | - 'span', |
|
24 | - 'strong', |
|
25 | - 'sub', |
|
26 | - 'sup', |
|
27 | - ); |
|
28 | - protected static $whiteSpacesTags = array( |
|
29 | - 'pre', |
|
30 | - 'script', |
|
31 | - 'textarea', |
|
32 | - ); |
|
33 | - public $name; |
|
34 | - public $attributes; |
|
35 | - public $block; |
|
36 | - public $selfClosing = false; |
|
7 | + protected static $inlineTags = array( |
|
8 | + 'a', |
|
9 | + 'abbr', |
|
10 | + 'acronym', |
|
11 | + 'b', |
|
12 | + 'br', |
|
13 | + 'code', |
|
14 | + 'em', |
|
15 | + 'font', |
|
16 | + 'i', |
|
17 | + 'img', |
|
18 | + 'ins', |
|
19 | + 'kbd', |
|
20 | + 'map', |
|
21 | + 'samp', |
|
22 | + 'small', |
|
23 | + 'span', |
|
24 | + 'strong', |
|
25 | + 'sub', |
|
26 | + 'sup', |
|
27 | + ); |
|
28 | + protected static $whiteSpacesTags = array( |
|
29 | + 'pre', |
|
30 | + 'script', |
|
31 | + 'textarea', |
|
32 | + ); |
|
33 | + public $name; |
|
34 | + public $attributes; |
|
35 | + public $block; |
|
36 | + public $selfClosing = false; |
|
37 | 37 | |
38 | - public function __construct($name, $block = null) |
|
39 | - { |
|
40 | - $this->name = $name; |
|
38 | + public function __construct($name, $block = null) |
|
39 | + { |
|
40 | + $this->name = $name; |
|
41 | 41 | |
42 | - $this->block = $block !== null |
|
43 | - ? $block |
|
44 | - : new Block(); |
|
42 | + $this->block = $block !== null |
|
43 | + ? $block |
|
44 | + : new Block(); |
|
45 | 45 | |
46 | - $this->attributes = array(); |
|
47 | - } |
|
46 | + $this->attributes = array(); |
|
47 | + } |
|
48 | 48 | |
49 | - public function isInline() |
|
50 | - { |
|
51 | - return in_array($this->name, static::$inlineTags); |
|
52 | - } |
|
49 | + public function isInline() |
|
50 | + { |
|
51 | + return in_array($this->name, static::$inlineTags); |
|
52 | + } |
|
53 | 53 | |
54 | - public function keepWhiteSpaces() |
|
55 | - { |
|
56 | - return in_array($this->name, static::$whiteSpacesTags); |
|
57 | - } |
|
54 | + public function keepWhiteSpaces() |
|
55 | + { |
|
56 | + return in_array($this->name, static::$whiteSpacesTags); |
|
57 | + } |
|
58 | 58 | |
59 | - public function hasConsecutiveTextNodes() |
|
60 | - { |
|
61 | - $nodes = $this->block->nodes; |
|
62 | - $prev = null; |
|
59 | + public function hasConsecutiveTextNodes() |
|
60 | + { |
|
61 | + $nodes = $this->block->nodes; |
|
62 | + $prev = null; |
|
63 | 63 | |
64 | - foreach ($nodes as $key => $node) { |
|
65 | - if ($prev !== null && isset($nodes[$prev]->isText) && $nodes[$prev]->isText && isset($node->isText) && $node->isText) { |
|
66 | - return false; |
|
67 | - } |
|
68 | - $prev = $key; |
|
69 | - } |
|
64 | + foreach ($nodes as $key => $node) { |
|
65 | + if ($prev !== null && isset($nodes[$prev]->isText) && $nodes[$prev]->isText && isset($node->isText) && $node->isText) { |
|
66 | + return false; |
|
67 | + } |
|
68 | + $prev = $key; |
|
69 | + } |
|
70 | 70 | |
71 | - return true; |
|
72 | - } |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - public function hasOnlyInlineNodes() |
|
75 | - { |
|
76 | - foreach ($this->block->nodes as $node) { |
|
77 | - if (!$node->isInline()) { |
|
78 | - return false; |
|
79 | - } |
|
80 | - } |
|
74 | + public function hasOnlyInlineNodes() |
|
75 | + { |
|
76 | + foreach ($this->block->nodes as $node) { |
|
77 | + if (!$node->isInline()) { |
|
78 | + return false; |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - return true; |
|
83 | - } |
|
82 | + return true; |
|
83 | + } |
|
84 | 84 | |
85 | - public function canInline() |
|
86 | - { |
|
87 | - return $this->hasOnlyInlineNodes() && $this->hasConsecutiveTextNodes(); |
|
88 | - } |
|
85 | + public function canInline() |
|
86 | + { |
|
87 | + return $this->hasOnlyInlineNodes() && $this->hasConsecutiveTextNodes(); |
|
88 | + } |
|
89 | 89 | } |
@@ -4,12 +4,12 @@ |
||
4 | 4 | |
5 | 5 | class When extends Node |
6 | 6 | { |
7 | - public $expr; |
|
8 | - public $block; |
|
7 | + public $expr; |
|
8 | + public $block; |
|
9 | 9 | |
10 | - public function __construct($expr, $block) |
|
11 | - { |
|
12 | - $this->expr = $expr; |
|
13 | - $this->block = $block; |
|
14 | - } |
|
10 | + public function __construct($expr, $block) |
|
11 | + { |
|
12 | + $this->expr = $expr; |
|
13 | + $this->block = $block; |
|
14 | + } |
|
15 | 15 | } |
@@ -4,11 +4,11 @@ |
||
4 | 4 | |
5 | 5 | class Literal extends Node |
6 | 6 | { |
7 | - public $string; |
|
7 | + public $string; |
|
8 | 8 | |
9 | - public function __construct($string) |
|
10 | - { |
|
11 | - // escape the chars '\', '\n', '\r\n' and "'" |
|
12 | - $this->string = preg_replace(array('/\\\\/', '/\\n|\\r\\n/', '/\'/'), array('\\\\', "\r", "\\'"), $string); |
|
13 | - } |
|
9 | + public function __construct($string) |
|
10 | + { |
|
11 | + // escape the chars '\', '\n', '\r\n' and "'" |
|
12 | + $this->string = preg_replace(array('/\\\\/', '/\\n|\\r\\n/', '/\'/'), array('\\\\', "\r", "\\'"), $string); |
|
13 | + } |
|
14 | 14 | } |
@@ -4,18 +4,18 @@ |
||
4 | 4 | |
5 | 5 | class Mixin extends Attributes |
6 | 6 | { |
7 | - public $name; |
|
8 | - public $arguments; |
|
9 | - public $block; |
|
10 | - public $attributes; |
|
11 | - public $call; |
|
7 | + public $name; |
|
8 | + public $arguments; |
|
9 | + public $block; |
|
10 | + public $attributes; |
|
11 | + public $call; |
|
12 | 12 | |
13 | - public function __construct($name, $arguments, $block, $call) |
|
14 | - { |
|
15 | - $this->name = $name; |
|
16 | - $this->arguments = $arguments; |
|
17 | - $this->block = $block; |
|
18 | - $this->attributes = array(); |
|
19 | - $this->call = $call; |
|
20 | - } |
|
13 | + public function __construct($name, $arguments, $block, $call) |
|
14 | + { |
|
15 | + $this->name = $name; |
|
16 | + $this->arguments = $arguments; |
|
17 | + $this->block = $block; |
|
18 | + $this->attributes = array(); |
|
19 | + $this->call = $call; |
|
20 | + } |
|
21 | 21 | } |