@@ -4,12 +4,12 @@ |
||
4 | 4 | |
5 | 5 | class Comment extends Node |
6 | 6 | { |
7 | - public $value; |
|
8 | - public $buffer; |
|
7 | + public $value; |
|
8 | + public $buffer; |
|
9 | 9 | |
10 | - public function __construct($value, $buffer) |
|
11 | - { |
|
12 | - $this->value = $value; |
|
13 | - $this->buffer = $buffer; |
|
14 | - } |
|
10 | + public function __construct($value, $buffer) |
|
11 | + { |
|
12 | + $this->value = $value; |
|
13 | + $this->buffer = $buffer; |
|
14 | + } |
|
15 | 15 | } |
@@ -5,12 +5,12 @@ |
||
5 | 5 | // cant use the keyword case as class name |
6 | 6 | class CaseNode extends Node |
7 | 7 | { |
8 | - public $expr; |
|
9 | - public $block; |
|
8 | + public $expr; |
|
9 | + public $block; |
|
10 | 10 | |
11 | - public function __construct($expr, $block = null) |
|
12 | - { |
|
13 | - $this->expr = $expr; |
|
14 | - $this->block = $block; |
|
15 | - } |
|
11 | + public function __construct($expr, $block = null) |
|
12 | + { |
|
13 | + $this->expr = $expr; |
|
14 | + $this->block = $block; |
|
15 | + } |
|
16 | 16 | } |
@@ -4,72 +4,72 @@ |
||
4 | 4 | |
5 | 5 | class Block extends Node |
6 | 6 | { |
7 | - public $isBlock = true; |
|
8 | - public $nodes = array(); |
|
7 | + public $isBlock = true; |
|
8 | + public $nodes = array(); |
|
9 | 9 | |
10 | - public function __construct($node = null) |
|
11 | - { |
|
12 | - if (null !== $node) { |
|
13 | - $this->push($node); |
|
14 | - } |
|
15 | - } |
|
10 | + public function __construct($node = null) |
|
11 | + { |
|
12 | + if (null !== $node) { |
|
13 | + $this->push($node); |
|
14 | + } |
|
15 | + } |
|
16 | 16 | |
17 | - public function replace($other) |
|
18 | - { |
|
19 | - $other->nodes = $this->nodes; |
|
20 | - } |
|
17 | + public function replace($other) |
|
18 | + { |
|
19 | + $other->nodes = $this->nodes; |
|
20 | + } |
|
21 | 21 | |
22 | - public function push($node) |
|
23 | - { |
|
24 | - return array_push($this->nodes, $node); |
|
25 | - } |
|
22 | + public function push($node) |
|
23 | + { |
|
24 | + return array_push($this->nodes, $node); |
|
25 | + } |
|
26 | 26 | |
27 | - public function isEmpty() |
|
28 | - { |
|
29 | - return 0 === count($this->nodes); |
|
30 | - } |
|
27 | + public function isEmpty() |
|
28 | + { |
|
29 | + return 0 === count($this->nodes); |
|
30 | + } |
|
31 | 31 | |
32 | - public function unshift($node) |
|
33 | - { |
|
34 | - return array_unshift($this->nodes, $node); |
|
35 | - } |
|
32 | + public function unshift($node) |
|
33 | + { |
|
34 | + return array_unshift($this->nodes, $node); |
|
35 | + } |
|
36 | 36 | |
37 | - public function getYield() |
|
38 | - { |
|
39 | - foreach ($this->nodes as $node) { |
|
40 | - if (isset($node->yield)) { |
|
41 | - return $node; |
|
42 | - } elseif (isset($node->block) && $yield = $node->block->getYield()) { |
|
43 | - return $yield; |
|
44 | - } |
|
45 | - } |
|
37 | + public function getYield() |
|
38 | + { |
|
39 | + foreach ($this->nodes as $node) { |
|
40 | + if (isset($node->yield)) { |
|
41 | + return $node; |
|
42 | + } elseif (isset($node->block) && $yield = $node->block->getYield()) { |
|
43 | + return $yield; |
|
44 | + } |
|
45 | + } |
|
46 | 46 | |
47 | - return false; |
|
48 | - } |
|
47 | + return false; |
|
48 | + } |
|
49 | 49 | |
50 | - public function includeBlock() |
|
51 | - { |
|
52 | - $ret = $this; |
|
53 | - foreach ($this->nodes as $node) { |
|
54 | - if (isset($node->yield)) { |
|
55 | - return $node; |
|
56 | - } |
|
50 | + public function includeBlock() |
|
51 | + { |
|
52 | + $ret = $this; |
|
53 | + foreach ($this->nodes as $node) { |
|
54 | + if (isset($node->yield)) { |
|
55 | + return $node; |
|
56 | + } |
|
57 | 57 | |
58 | - if (isset($node->block) && $yield = $node->block->getYield()) { |
|
59 | - return $yield; |
|
60 | - } |
|
58 | + if (isset($node->block) && $yield = $node->block->getYield()) { |
|
59 | + return $yield; |
|
60 | + } |
|
61 | 61 | |
62 | - if (isset($node->textOnly)) { |
|
63 | - continue; |
|
64 | - } |
|
62 | + if (isset($node->textOnly)) { |
|
63 | + continue; |
|
64 | + } |
|
65 | 65 | |
66 | - if (method_exists($node, 'includeBlock')) { |
|
67 | - $ret = $node->includeBlock(); |
|
68 | - } elseif (isset($node->block) && !$node->block->isEmpty()) { |
|
69 | - $ret = $node->block->includeBlock(); |
|
70 | - } |
|
71 | - } |
|
66 | + if (method_exists($node, 'includeBlock')) { |
|
67 | + $ret = $node->includeBlock(); |
|
68 | + } elseif (isset($node->block) && !$node->block->isEmpty()) { |
|
69 | + $ret = $node->block->includeBlock(); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return $ret; |
|
74 | - } |
|
73 | + return $ret; |
|
74 | + } |
|
75 | 75 | } |
@@ -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 | } |