1 | <?php |
||
11 | class CompilerBuffer { |
||
12 | const STYLE_JOIN = 'join'; |
||
13 | const STYLE_ARRAY = 'array'; |
||
14 | |||
15 | /** |
||
16 | * @var ComponentBuffer[] |
||
17 | */ |
||
18 | private $buffers; |
||
19 | |||
20 | /** |
||
21 | * @var ComponentBuffer |
||
22 | */ |
||
23 | private $current; |
||
24 | |||
25 | private $currentName; |
||
26 | |||
27 | private $basename; |
||
28 | |||
29 | private $style = self::STYLE_JOIN; |
||
30 | |||
31 | /** |
||
32 | * @var array |
||
33 | */ |
||
34 | private $defaults; |
||
35 | |||
36 | /** |
||
37 | * @var \SplObjectStorage |
||
38 | */ |
||
39 | private $nodeProps; |
||
40 | |||
41 | 53 | public function __construct($style = self::STYLE_JOIN, array $defaults = []) { |
|
52 | |||
53 | /** |
||
54 | * Select a specific component buffer. |
||
55 | * @param $component |
||
56 | */ |
||
57 | 53 | public function select($component) { |
|
69 | |||
70 | 51 | public function echoLiteral($value) { |
|
73 | |||
74 | 41 | public function echoCode($php) { |
|
77 | |||
78 | 53 | public function appendCode($php) { |
|
81 | |||
82 | 53 | public function indent($add) { |
|
85 | |||
86 | 14 | public function depth($add = 1) { |
|
89 | |||
90 | 17 | public function depthName($name, $add = 0) { |
|
93 | |||
94 | 53 | public function pushScope(array $vars) { |
|
97 | |||
98 | 53 | public function popScope() { |
|
101 | |||
102 | 48 | public function getScopeVariables() { |
|
105 | |||
106 | 53 | public function flush() { |
|
114 | |||
115 | private function flushJoin() { |
||
121 | |||
122 | 11 | private function flushArray() { |
|
144 | |||
145 | 3 | protected function px($add = 0) { |
|
148 | |||
149 | /** |
||
150 | * Get the style. |
||
151 | * |
||
152 | * @return string Returns the style. |
||
153 | */ |
||
154 | 53 | public function getStyle() { |
|
157 | |||
158 | /** |
||
159 | * Set the style. |
||
160 | * |
||
161 | * @param string $style One of the **STYLE_*** constants. |
||
162 | * @return $this |
||
163 | */ |
||
164 | public function setStyle($style) { |
||
168 | |||
169 | /** |
||
170 | * Get the basename. |
||
171 | * |
||
172 | * @return string Returns the basename. |
||
173 | */ |
||
174 | public function getBasename() { |
||
177 | |||
178 | /** |
||
179 | * Set the basename. |
||
180 | * |
||
181 | * @param string $basename |
||
182 | * @return $this |
||
183 | */ |
||
184 | 53 | public function setBasename($basename) { |
|
188 | |||
189 | 53 | public function getNodeProp(\DOMNode $node, $name, $default = null) { |
|
195 | |||
196 | 21 | public function setNodeProp(\DOMNode $node = null, $name, $value) { |
|
208 | |||
209 | 11 | public function getIndent() { |
|
212 | |||
213 | 11 | public function getDepth() { |
|
216 | |||
217 | public function getScope() { |
||
220 | |||
221 | 11 | public function getAllScopes() { |
|
224 | } |
||
225 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.