Completed
Push — master ( 92bccd...8fac4c )
by Fenz
02:24
created
libs/Embedment/CodeEmbedment.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @param  \Htsl\ReadingBuffer\Line $line
16 16
 	 *
17
-	 * @return \Htsl\Embedment\Contracts
17
+	 * @return CodeEmbedment
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,13 +18,13 @@
 block discarded – undo
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
21
-		$content= '<code>'.htmlentities($line->fullContent).'</code>';
21
+		$content='<code>'.htmlentities($line->fullContent).'</code>';
22 22
 
23
-		$indentation= $this->document->indentation;
23
+		$indentation=$this->document->indentation;
24 24
 
25
-		false!==$indentation and $content= str_repeat($indentation,$this->document->indentLevel).$content."\n";
25
+		false!==$indentation and $content=str_repeat($indentation, $this->document->indentLevel).$content."\n";
26 26
 
27
-		$this->content.= $content;
27
+		$this->content.=$content;
28 28
 
29 29
 		return $this;
30 30
 	}
Please login to merge, or discard this patch.
libs/Embedment/CssEmbedment.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @param  \Htsl\ReadingBuffer\Line $line
16 16
 	 *
17
-	 * @return \Htsl\Embedment\Contracts
17
+	 * @return CssEmbedment
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
21
-		$this->content.= $line->content;
21
+		$this->content.=$line->content;
22 22
 		return $this;
23 23
 	}
24 24
 }
Please login to merge, or discard this patch.
libs/Embedment/JsEmbedment.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
 	 *
23 23
 	 * @param  \Htsl\ReadingBuffer\Line $line
24 24
 	 *
25
-	 * @return \Htsl\Embedment\Contracts
25
+	 * @return JsEmbedment
26 26
 	 */
27 27
 	public function parseLine( Line$line ):parent
28 28
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	 */
27 27
 	public function parseLine( Line$line ):parent
28 28
 	{
29
-		$this->content.= $line->fullContent."\n";
29
+		$this->content.=$line->fullContent."\n";
30 30
 		return $this;
31 31
 	}
32 32
 }
Please login to merge, or discard this patch.
libs/Embedment/PhpEmbedment.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @param  \Htsl\ReadingBuffer\Line $line
16 16
 	 *
17
-	 * @return \Htsl\Embedment\Contracts
17
+	 * @return PhpEmbedment
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
21
-		$this->content.= $line->content;
21
+		$this->content.=$line->content;
22 22
 		return $this;
23 23
 	}
24 24
 }
Please login to merge, or discard this patch.
libs/Embedment/TextEmbedment.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @param  \Htsl\ReadingBuffer\Line $line
16 16
 	 *
17
-	 * @return \Htsl\Embedment\Contracts
17
+	 * @return TextEmbedment
18 18
 	 */
19 19
 	public function parseLine( Line$line ):parent
20 20
 	{
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	 */
27 27
 	public function parseLine( Line$line ):parent
28 28
 	{
29
-		$this->content.= $line->fullContent."\n";
29
+		$this->content.=$line->fullContent."\n";
30 30
 		return $this;
31 31
 	}
32 32
 }
Please login to merge, or discard this patch.
libs/Htsl.php 3 patches
Braces   +5 added lines, -8 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 
68 68
 		if( $toFile ){
69 69
 			return file_put_contents($toFile,$result);
70
-		}else{
70
+		} else{
71 71
 			return $result;
72 72
 		}
73 73
 	}
@@ -159,15 +159,12 @@  discard block
 block discarded – undo
159 159
 
160 160
 		if( '/'===$filePath{0} ){
161 161
 			if( is_null($path) )
162
-				{ return $filePath; }
163
-			else
162
+				{ return $filePath; } else
164 163
 				{ return $this->basePath.$filePath; }
165
-		}else{
164
+		} else{
166 165
 			if( !strlen($path) )
167
-				{ return $this->basePath.'/'.$filePath; }
168
-			elseif( '/'===substr($path,-1) )
169
-				{ return $path.$filePath; }
170
-			else
166
+				{ return $this->basePath.'/'.$filePath; } elseif( '/'===substr($path,-1) )
167
+				{ return $path.$filePath; } else
171 168
 				{ return $path.'/'.$filePath; }
172 169
 		}
173 170
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param array $config
36 36
 	 */
37
-	public function __construct( array$config=[] )
37
+	public function __construct( array$config=[ ] )
38 38
 	{
39
-		$this->config= array_replace_recursive($this->getDefaultConfigs(),$config);
39
+		$this->config=array_replace_recursive($this->getDefaultConfigs(), $config);
40 40
 	}
41 41
 
42 42
 	/**
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function parse( string$content ):string
50 50
 	{
51
-		return $this->execute(new StringBuffer($this,$content));
51
+		return $this->execute(new StringBuffer($this, $content));
52 52
 	}
53 53
 
54 54
 	/**
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public function compile( string$fromFile, string$toFile=null )
63 63
 	{
64
-		$fromFile= $this->getFilePath($fromFile);
64
+		$fromFile=$this->getFilePath($fromFile);
65 65
 
66
-		$result= $this->execute(new FileBuffer($this,$fromFile));
66
+		$result=$this->execute(new FileBuffer($this, $fromFile));
67 67
 
68 68
 		if( $toFile ){
69
-			return file_put_contents($toFile,$result);
69
+			return file_put_contents($toFile, $result);
70 70
 		}else{
71 71
 			return $result;
72 72
 		}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function setBasePath( string$basePath ):self
95 95
 	{
96
-		$this->basePath= '/'===substr($basePath,-1) ? substr($basePath,0,-1) : $basePath;
96
+		$this->basePath='/'===substr($basePath, -1)? substr($basePath, 0, -1) : $basePath;
97 97
 
98 98
 		return $this;
99 99
 	}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function execute( ABuffer$buffer ):string
119 119
 	{
120
-		return (new Document($this,$buffer))->content;
120
+		return (new Document($this, $buffer))->content;
121 121
 	}
122 122
 
123 123
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 */
130 130
 	public function getConfig( string...$keys )
131 131
 	{
132
-		$result= $this->config;
132
+		$result=$this->config;
133 133
 
134 134
 		foreach( $keys as $key ){
135
-			if( !isset($result[$key]) )
135
+			if( !isset($result[ $key ]) )
136 136
 				{ return null; }
137 137
 
138
-			$result= $result[$key];
138
+			$result=$result[ $key ];
139 139
 		}
140 140
 
141 141
 		return $result;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		}else{
166 166
 			if( !strlen($path) )
167 167
 				{ return $this->basePath.'/'.$filePath; }
168
-			elseif( '/'===substr($path,-1) )
168
+			elseif( '/'===substr($path, -1) )
169 169
 				{ return $path.$filePath; }
170 170
 			else
171 171
 				{ return $path.'/'.$filePath; }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function getFileContent( string$filePath ):string
183 183
 	{
184
-		return isset($this->fileGetter) ? $this->fileGetter($filePath) : file_get_contents($filePath);
184
+		return isset($this->fileGetter)? $this->fileGetter($filePath) : file_get_contents($filePath);
185 185
 	}
186 186
 
187 187
 	/**
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
 	/**
124 124
 	 * Getting the config of Htsl.
125 125
 	 *
126
-	 * @param  string $keys
126
+	 * @param  string[] $keys
127 127
 	 *
128 128
 	 * @return mixed
129 129
 	 */
Please login to merge, or discard this patch.
libs/Helper/TSetter.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
 	{
17 17
 		if( is_callable([static::class, $setter= 'set'.implode('',array_map('ucfirst',explode('_',$attribute))),]) ){
18 18
 			return static::$setter($value);
19
-		}else{
19
+		} else{
20 20
 			throw new \Exception(static::class.' has no attribute named '.$attribute);
21 21
 		}
22 22
 	}
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 	 */
15 15
 	public function __set( $attribute, $value )
16 16
 	{
17
-		if( is_callable([static::class, $setter= 'set'.implode('',array_map('ucfirst',explode('_',$attribute))),]) ){
17
+		if( is_callable([ static::class, $setter='set'.implode('', array_map('ucfirst', explode('_', $attribute))), ]) ){
18 18
 			return static::$setter($value);
19 19
 		}else{
20 20
 			throw new \Exception(static::class.' has no attribute named '.$attribute);
Please login to merge, or discard this patch.
libs/Parser/Document.php 5 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@
 block discarded – undo
165 165
 			return $this;
166 166
 		}
167 167
 		return $this->lineByLine()
168
-		            ->bubbleSections()
168
+					->bubbleSections()
169 169
 		;
170 170
 	}
171 171
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
 	 *
213 213
 	 * @param  [ string, ] ...$keys
214 214
 	 *
215
-	 * @return mixed
215
+	 * @return string
216 216
 	 */
217 217
 	public function getConfig( string...$keys )
218 218
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		}
324 324
 
325 325
 		$this->docType= $line->content;
326
-		$docTypeContent= $this->getConfig('doc_types') or $this->throw("DocType $this->docType is not supported");
326
+		$docTypeContent= $this->getConfig('doc_types') or $this->throw("doctype $this->docType is not supported");
327 327
 
328 328
 		$this->indentation= $this->htsl->getConfig('indentation',$this->docType) ?? ( function( $scalarOrFalse ){ return is_scalar($scalarOrFalse)?$scalarOrFalse:false; } )($this->htsl->getConfig('indentation'));
329 329
 
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 		}
786 786
 
787 787
 		if( isset($this->parent->sections[$section->name]) ){
788
-			$this->throw("Section {$section->name} already defined.");
788
+			$this->throw("section {$section->name} already defined.");
789 789
 		}
790 790
 
791 791
 		$this->currentSection= $section;
Please login to merge, or discard this patch.
Braces   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			$this->parent= $parent;
192 192
 			$this->docType= $parent->docType;
193 193
 			$this->indentation= $parent->indentation;
194
-		}else{
194
+		} else{
195 195
 			$this->parseFirstLine();
196 196
 		}
197 197
 	}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	{
237 237
 		if( $this->parent ){
238 238
 			return $this->execute()->parent->getContent();
239
-		}else{
239
+		} else{
240 240
 			return $this->execute()->content;
241 241
 		}
242 242
 	}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
 			if( $this->embedment ){
376 376
 				$this->embeddingParse($line);
377
-			}else{
377
+			} else{
378 378
 				$this->parseLine($line);
379 379
 			}
380 380
 		}
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 	{
402 402
 		if( $line->content==='<}' ){
403 403
 			$this->breakEmbedding();
404
-		}else{
404
+		} else{
405 405
 			$this->embedment->parseLine($line->getSubIndentLine());
406 406
 		}
407 407
 		return $this;
@@ -864,9 +864,9 @@  discard block
 block discarded – undo
864 864
 
865 865
 		if( $level<=0 ){
866 866
 			$this->closeNodes(-$level);
867
-		}elseif( $level==1 ){
867
+		} elseif( $level==1 ){
868 868
 			$this->level+= 1;
869
-		}else{
869
+		} else{
870 870
 			$this->throw('Indent error.');
871 871
 		}
872 872
 
@@ -902,7 +902,9 @@  discard block
 block discarded – undo
902 902
 	 */
903 903
 	protected function closeNodes( int$level=0 ):self
904 904
 	{
905
-		if( empty($this->openedNodes) ) return $this;
905
+		if( empty($this->openedNodes) ){
906
+			return $this;
907
+		}
906 908
 
907 909
 		while( $level-->=0 ){
908 910
 			$node= array_pop($this->openedNodes);
@@ -990,7 +992,7 @@  discard block
 block discarded – undo
990 992
 	{
991 993
 		if( $this->currentSection ){
992 994
 			$this->currentSection->append($content);
993
-		}else{
995
+		} else{
994 996
 			$this->content.=$content;
995 997
 		}
996 998
 
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @var int
92 92
 	 */
93
-	private $level= 0;
93
+	private $level=0;
94 94
 
95 95
 	/**
96 96
 	 * Section indent level.
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @var int
101 101
 	 */
102
-	private $sectionLevel= 0;
102
+	private $sectionLevel=0;
103 103
 
104 104
 	/**
105 105
 	 * Opened nodes.
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @var [ Htsl\Parser\Node\Contracts\ANode, ]
110 110
 	 */
111
-	private $openedNodes= [];
111
+	private $openedNodes=[ ];
112 112
 
113 113
 	/**
114 114
 	 * Current scopes.
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @var [ Htsl\Parser\Node\Contracts\ANode, ]
119 119
 	 */
120
-	private $scopes= [];
120
+	private $scopes=[ ];
121 121
 
122 122
 	/**
123 123
 	 * Current line number.
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @var int
128 128
 	 */
129
-	private $lineNumber= 0;
129
+	private $lineNumber=0;
130 130
 
131 131
 	/**
132 132
 	 * Current line.
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @var [ Htsl\Parser\Section, ]
146 146
 	 */
147
-	private $sections=[];
147
+	private $sections=[ ];
148 148
 
149 149
 	/**
150 150
 	 * Whether the document is executed.
@@ -184,13 +184,13 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function __construct( Htsl$htsl, Buffer$buffer, self$parent=null )
186 186
 	{
187
-		$this->htsl= $htsl;
188
-		$this->buffer= $buffer;
187
+		$this->htsl=$htsl;
188
+		$this->buffer=$buffer;
189 189
 
190 190
 		if( $parent ){
191
-			$this->parent= $parent;
192
-			$this->docType= $parent->docType;
193
-			$this->indentation= $parent->indentation;
191
+			$this->parent=$parent;
192
+			$this->docType=$parent->docType;
193
+			$this->indentation=$parent->indentation;
194 194
 		}else{
195 195
 			$this->parseFirstLine();
196 196
 		}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	protected function getLine():Line
252 252
 	{
253 253
 		do{
254
-			$line= $this->buffer->getLine();
254
+			$line=$this->buffer->getLine();
255 255
 		}while( $line->isEmpty() && $line->hasMore() );
256 256
 
257 257
 		return $line;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public function getConfig( string...$keys )
270 270
 	{
271
-		return $this->htsl->getConfig(array_shift($keys),$this->docType,...$keys);
271
+		return $this->htsl->getConfig(array_shift($keys), $this->docType, ...$keys);
272 272
 	}
273 273
 
274 274
 	/**
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 	 */
317 317
 	protected function parseFirstLine():self
318 318
 	{
319
-		$line= $this->getLine();
319
+		$line=$this->getLine();
320 320
 
321 321
 		if( '@'===$line->getChar(0) ){
322 322
 			return $this->setExtending($line);
323 323
 		}
324 324
 
325
-		$this->docType= $line->content;
326
-		$docTypeContent= $this->getConfig('doc_types') or $this->throw("DocType $this->docType is not supported");
325
+		$this->docType=$line->content;
326
+		$docTypeContent=$this->getConfig('doc_types') or $this->throw("DocType $this->docType is not supported");
327 327
 
328
-		$this->indentation= $this->htsl->getConfig('indentation',$this->docType) ?? ( function( $scalarOrFalse ){ return is_scalar($scalarOrFalse)?$scalarOrFalse:false; } )($this->htsl->getConfig('indentation'));
328
+		$this->indentation=$this->htsl->getConfig('indentation', $this->docType) ?? (function( $scalarOrFalse ){ return is_scalar($scalarOrFalse)? $scalarOrFalse : false; } )($this->htsl->getConfig('indentation'));
329 329
 
330 330
 		$this->appendLine($docTypeContent);
331 331
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
 	protected function setExtending( Line$firstLine ):self
345 345
 	{
346
-		switch( $name= $firstLine->pregGet('/(?<=^@)[\w-:]+/') ){
346
+		switch( $name=$firstLine->pregGet('/(?<=^@)[\w-:]+/') ){
347 347
 			default:{
348 348
 				$this->throw("The @$name is not supported.");
349 349
 			}break;
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 */
370 370
 	protected function lineByLine():self
371 371
 	{
372
-		while( ($line= $this->getLine())->hasMore() ){
373
-			$this->lineNumber+= 1;
372
+		while( ($line=$this->getLine())->hasMore() ){
373
+			$this->lineNumber+=1;
374 374
 
375 375
 			if( $this->embedment ){
376 376
 				$this->embeddingParse($line);
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
 		$this->closeNodes($this->level);
385 385
 
386
-		$this->isExecuted= true;
386
+		$this->isExecuted=true;
387 387
 
388 388
 		return $this;
389 389
 	}
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	protected function startEmbedding( string$embedType ):self
420 420
 	{
421
-		$embedmentClass= '\\Htsl\\Embedment\\'.ucfirst($embedType).'Embedment';
421
+		$embedmentClass='\\Htsl\\Embedment\\'.ucfirst($embedType).'Embedment';
422 422
 		class_exists($embedmentClass) or $this->throw("Embed type $embedType not exists.");
423 423
 
424
-		$this->embedment= new $embedmentClass($this);
424
+		$this->embedment=new $embedmentClass($this);
425 425
 
426 426
 		return $this;
427 427
 	}
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	public function breakEmbedding():self
437 437
 	{
438 438
 		$this->append($this->embedment->getContent());
439
-		$this->embedment= null;
439
+		$this->embedment=null;
440 440
 
441 441
 		return $this;
442 442
 	}
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 */
453 453
 	protected function parseLine( Line$line ):self
454 454
 	{
455
-		$this->currentLine= $line;
455
+		$this->currentLine=$line;
456 456
 		$this->setLevel($line->getIndentLevel());
457 457
 
458 458
 		$this->{'parse'.ucfirst($this->getLineType($line))}($line);
@@ -471,10 +471,10 @@  discard block
 block discarded – undo
471 471
 	 */
472 472
 	protected function getLineType( Line$line ):string
473 473
 	{
474
-		$possibleType= self::POSSIBLE_LINE_TYPES;
474
+		$possibleType=self::POSSIBLE_LINE_TYPES;
475 475
 
476 476
 		for( $i=0; is_array($possibleType); ++$i ){
477
-			$possibleType= $possibleType[$line->getChar($i)]??$possibleType[' '];
477
+			$possibleType=$possibleType[ $line->getChar($i) ]??$possibleType[ ' ' ];
478 478
 		}
479 479
 
480 480
 		return $possibleType;
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 	 *
490 490
 	 * @todo Make this const private when php 7.1
491 491
 	 */
492
-	const POSSIBLE_LINE_TYPES= [
492
+	const POSSIBLE_LINE_TYPES=[
493 493
 		'`'=> [
494 494
 			'='=> 'expressionHtmlLine',
495 495
 			' '=> 'htmlLine',
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 	 */
514 514
 	protected function parseHtmlLine( Line$line ):self
515 515
 	{
516
-		return $this->openNode(new StringNode($this,$line))->appendLine($line->slice(1));
516
+		return $this->openNode(new StringNode($this, $line))->appendLine($line->slice(1));
517 517
 	}
518 518
 
519 519
 	/**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 */
528 528
 	protected function parseStringLine( Line$line ):self
529 529
 	{
530
-		return $this->openNode(new StringNode($this,$line))->appendLine($this->htmlEntities(trim($line->getContent())));
530
+		return $this->openNode(new StringNode($this, $line))->appendLine($this->htmlEntities(trim($line->getContent())));
531 531
 	}
532 532
 
533 533
 	/**
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
 	 */
542 542
 	protected function parseExpressionLine( Line$line ):self
543 543
 	{
544
-		$content=  $line->slice(1);
545
-		$ent_flag= var_export($this->htsl->getConfig('ENT_flags',$this->docType),true);
546
-		$charset=   var_export($this->htsl->getConfig('charset'),true);
544
+		$content=$line->slice(1);
545
+		$ent_flag=var_export($this->htsl->getConfig('ENT_flags', $this->docType), true);
546
+		$charset=var_export($this->htsl->getConfig('charset'), true);
547 547
 
548
-		return $this->openNode(new StringNode($this,$line))->appendLine("<?=htmlentities($content,$ent_flag,$charset,false)?>");
548
+		return $this->openNode(new StringNode($this, $line))->appendLine("<?=htmlentities($content,$ent_flag,$charset,false)?>");
549 549
 	}
550 550
 
551 551
 	/**
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 	 */
560 560
 	protected function parseExpressionHtmlLine( Line$line ):self
561 561
 	{
562
-		$content=  $line->slice(1);
562
+		$content=$line->slice(1);
563 563
 
564
-		return $this->openNode(new StringNode($this,$line))->appendLine("<?$content?>");
564
+		return $this->openNode(new StringNode($this, $line))->appendLine("<?$content?>");
565 565
 	}
566 566
 
567 567
 	/**
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
 	 */
576 576
 	protected function parseCommentLine( Line$line ):self
577 577
 	{
578
-		$node= new CommentNode($this,$line);
578
+		$node=new CommentNode($this, $line);
579 579
 
580 580
 		return $this->openNode($node)->appendLine($node->open());
581 581
 	}
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 	 */
592 592
 	protected function parseTagLine( Line$line ):self
593 593
 	{
594
-		$node= new TagNode($this,$line);
594
+		$node=new TagNode($this, $line);
595 595
 
596 596
 		$this->appendLine($node->open());
597 597
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 */
612 612
 	protected function parseControlLine( Line$line ):self
613 613
 	{
614
-		$node= new ControlNode($this,$line);
614
+		$node=new ControlNode($this, $line);
615 615
 
616 616
 		return $this->appendLine($node->open())->openNode($node);
617 617
 	}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 	 */
628 628
 	protected function parseDocControlLine( Line$line ):self
629 629
 	{
630
-		switch( $name= $line->pregGet('/(?<=^@)[\w-:]+/') ){
630
+		switch( $name=$line->pregGet('/(?<=^@)[\w-:]+/') ){
631 631
 			default:{
632 632
 				$this->throw("The @$name is not supported.");
633 633
 			}break;
@@ -659,10 +659,10 @@  discard block
 block discarded – undo
659 659
 	 */
660 660
 	protected function extend( string$fileName ):self
661 661
 	{
662
-		$this->parent= new static($this->htsl,$this->buffer->goSide($fileName));
662
+		$this->parent=new static($this->htsl, $this->buffer->goSide($fileName));
663 663
 
664
-		$this->docType= $this->parent->docType;
665
-		$this->indentation= $this->parent->indentation;
664
+		$this->docType=$this->parent->docType;
665
+		$this->indentation=$this->parent->indentation;
666 666
 
667 667
 		return $this;
668 668
 	}
@@ -676,15 +676,15 @@  discard block
 block discarded – undo
676 676
 	 *
677 677
 	 * @return \Htsl\Parser\Document
678 678
 	 */
679
-	protected function include( Line$line ):self
679
+	protected function include(Line$line):self
680 680
 	{
681
-		$inclued= (new static($this->htsl,$this->buffer->goSide($line->pregGet('/(?<=\( ).*(?= \))/')),$this))->execute()->content;
681
+		$inclued=(new static($this->htsl, $this->buffer->goSide($line->pregGet('/(?<=\( ).*(?= \))/')), $this))->execute()->content;
682 682
 
683 683
 		if( false!==$this->indentation ){
684
-			$inclued= preg_replace('/(?<=^|\\n)(?!$)/',str_repeat($this->indentation,$this->level-$this->sectionLevel),$inclued);
684
+			$inclued=preg_replace('/(?<=^|\\n)(?!$)/', str_repeat($this->indentation, $this->level-$this->sectionLevel), $inclued);
685 685
 		}
686 686
 
687
-		$node= new StringNode($this,$line);
687
+		$node=new StringNode($this, $line);
688 688
 
689 689
 		$this->openNode($node);
690 690
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	 */
705 705
 	protected function defineSection( Line$line ):self
706 706
 	{
707
-		$node= new SectionNode($this,$line);
707
+		$node=new SectionNode($this, $line);
708 708
 
709 709
 		$node->open();
710 710
 
@@ -724,22 +724,22 @@  discard block
 block discarded – undo
724 724
 	 */
725 725
 	protected function showSection( Line$line ):self
726 726
 	{
727
-		$sectionName= $line->pregGet('/(?<=\( ).*(?= \))/');
727
+		$sectionName=$line->pregGet('/(?<=\( ).*(?= \))/');
728 728
 
729
-		if( !isset($this->sections[$sectionName]) ){
730
-			$this->openNode(new StringNode($this,$line));
729
+		if( !isset($this->sections[ $sectionName ]) ){
730
+			$this->openNode(new StringNode($this, $line));
731 731
 
732 732
 			return $this;
733 733
 		}
734
-		$content= $this->sections[$sectionName]->content;
734
+		$content=$this->sections[ $sectionName ]->content;
735 735
 
736 736
 		if( false!==$this->indentation ){
737
-			$content= preg_replace('/(?<=^|\\n)(?!$)/',str_repeat($this->indentation,$this->level),$content);
737
+			$content=preg_replace('/(?<=^|\\n)(?!$)/', str_repeat($this->indentation, $this->level), $content);
738 738
 		}
739 739
 
740 740
 		$this->append($content);
741 741
 
742
-		$node= new NamelessSectionNode($this,$line);
742
+		$node=new NamelessSectionNode($this, $line);
743 743
 
744 744
 		$node->open();
745 745
 
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	public function setSection( Section$section=null ):self
759 759
 	{
760 760
 		if( !$section ){
761
-			$this->sectionLevel= 0;
762
-			$this->currentSection= null;
761
+			$this->sectionLevel=0;
762
+			$this->currentSection=null;
763 763
 
764 764
 			return $this;
765 765
 		}
@@ -768,17 +768,17 @@  discard block
 block discarded – undo
768 768
 			$this->throw('Nesting definition of section is forbidden.');
769 769
 		}
770 770
 
771
-		if( isset($this->parent->sections[$section->name]) ){
771
+		if( isset($this->parent->sections[ $section->name ]) ){
772 772
 			$this->throw("Section {$section->name} already defined.");
773 773
 		}
774 774
 
775
-		$this->currentSection= $section;
775
+		$this->currentSection=$section;
776 776
 
777 777
 		if( $section->name ){
778
-			$this->parent->sections[$section->name]=$section;
778
+			$this->parent->sections[ $section->name ]=$section;
779 779
 		}
780 780
 
781
-		$this->sectionLevel= $this->level+1;
781
+		$this->sectionLevel=$this->level+1;
782 782
 
783 783
 		return $this;
784 784
 	}
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
 	{
795 795
 		if( $this->parent ){
796 796
 			foreach( $this->sections as $name=>$section ){
797
-				if( !isset($this->parent->sections[$name]) ){
798
-					$this->parent->sections[$name]=$section;
797
+				if( !isset($this->parent->sections[ $name ]) ){
798
+					$this->parent->sections[ $name ]=$section;
799 799
 				};
800 800
 			}
801 801
 		}
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 	 */
815 815
 	public function htmlEntities( string$input ):string
816 816
 	{
817
-		return htmlentities($input,$this->htsl->getConfig('ENT_flags',$this->docType),$this->htsl->getConfig('charset'),false);
817
+		return htmlentities($input, $this->htsl->getConfig('ENT_flags', $this->docType), $this->htsl->getConfig('charset'), false);
818 818
 	}
819 819
 
820 820
 	/**
@@ -826,12 +826,12 @@  discard block
 block discarded – undo
826 826
 	 */
827 827
 	protected function setLevel( int$level ):self
828 828
 	{
829
-		$level-= $this->level;
829
+		$level-=$this->level;
830 830
 
831 831
 		if( $level<=0 ){
832 832
 			$this->closeNodes(-$level);
833 833
 		}elseif( $level==1 ){
834
-			$this->level+= 1;
834
+			$this->level+=1;
835 835
 		}else{
836 836
 			$this->throw('Indent error.');
837 837
 		}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 */
851 851
 	protected function openNode( Node$node ):self
852 852
 	{
853
-		array_push($this->openedNodes,$node);
853
+		array_push($this->openedNodes, $node);
854 854
 
855 855
 		$node->scope and $this->setScope($node);
856 856
 
@@ -871,13 +871,13 @@  discard block
 block discarded – undo
871 871
 		if( empty($this->openedNodes) ) return $this;
872 872
 
873 873
 		while( $level-->=0 ){
874
-			$node= array_pop($this->openedNodes);
874
+			$node=array_pop($this->openedNodes);
875 875
 
876 876
 			$node->scope and $this->removeScope($node);
877 877
 
878 878
 			$closer=$node->close($this->currentLine) and $this->appendLine($closer);
879 879
 
880
-			$this->level-= $level>=0 ?1:0;
880
+			$this->level-=$level>=0? 1 : 0;
881 881
 		}
882 882
 
883 883
 		return $this;
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	 */
893 893
 	protected function setScope( Node$scope ):int
894 894
 	{
895
-		return array_unshift($this->scopes,$scope);
895
+		return array_unshift($this->scopes, $scope);
896 896
 	}
897 897
 
898 898
 	/**
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 	 */
905 905
 	public function getScope()
906 906
 	{
907
-		return $this->scopes[0]??null;
907
+		return $this->scopes[ 0 ]??null;
908 908
 	}
909 909
 
910 910
 	/**
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
 	protected function appendLine( string$content ):self
938 938
 	{
939 939
 		if( false!==$this->indentation ){
940
-			$content= str_repeat($this->indentation,$this->level-$this->sectionLevel).$content."\n";
940
+			$content=str_repeat($this->indentation, $this->level-$this->sectionLevel).$content."\n";
941 941
 		}
942 942
 
943 943
 		return $this->append($content);
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 	 *
985 985
 	 * @throw \Htsl\Parser\HtslParsingException
986 986
 	 */
987
-	public function throw( string$message )
987
+	public function throw(string$message)
988 988
 	{
989 989
 		throw new HtslParsingException("$message at file {$this->buffer->filePath} line $this->lineNumber");
990 990
 	}
Please login to merge, or discard this patch.
libs/Parser/Node/CommentNode.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -36,8 +36,8 @@
 block discarded – undo
36 36
 	public function open():string
37 37
 	{
38 38
 		return $this->htmlComment ?
39
-		                         '<!--'.str_replace('-->','--'.chr(0xC).'>',substr($this->line->getContent(),1)):
40
-		                         '<?php /* '.substr($this->line->getContent(),2);
39
+								 '<!--'.str_replace('-->','--'.chr(0xC).'>',substr($this->line->getContent(),1)):
40
+								 '<?php /* '.substr($this->line->getContent(),2);
41 41
 	}
42 42
 
43 43
 	/**
Please login to merge, or discard this patch.
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	protected function construct():parent
26 26
 	{
27
-		$this->htmlComment= '!'!==$this->line->getChar(1);
27
+		$this->htmlComment='!'!==$this->line->getChar(1);
28 28
 		return $this;
29 29
 	}
30 30
 
@@ -35,9 +35,8 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function open():string
37 37
 	{
38
-		return $this->htmlComment ?
39
-		                         '<!--'.str_replace('-->','--'.chr(0xC).'>',substr($this->line->getContent(),1)):
40
-		                         '<?php /* '.substr($this->line->getContent(),2);
38
+		return $this->htmlComment?
39
+		                         '<!--'.str_replace('-->', '--'.chr(0xC).'>', substr($this->line->getContent(), 1)) : '<?php /* '.substr($this->line->getContent(), 2);
41 40
 	}
42 41
 
43 42
 	/**
@@ -49,6 +48,6 @@  discard block
 block discarded – undo
49 48
 	 */
50 49
 	public function close( Line$closerLine ):string
51 50
 	{
52
-		return $this->htmlComment ? '-->' : ' */ ?>';
51
+		return $this->htmlComment? '-->' : ' */ ?>';
53 52
 	}
54 53
 }
Please login to merge, or discard this patch.