Completed
Pull Request — master (#1)
by Fenz
07:21
created
libs/Embedment/PhpEmbedment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
      *
17 17
      * @return \Htsl\Embedment\Contracts
18 18
      */
19
-    public function parseLine(Line $line):parent
19
+    public function parseLine( Line $line ):parent
20 20
     {
21
-        $this->content .= $line->content;
21
+        $this->content.=$line->content;
22 22
 
23 23
         return $this;
24 24
     }
Please login to merge, or discard this patch.
libs/Embedment/CodeEmbedment.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@
 block discarded – undo
16 16
      *
17 17
      * @return \Htsl\Embedment\Contracts
18 18
      */
19
-    public function parseLine(Line $line):parent
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/Contracts/AEmbedment.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      *
15 15
      * @var string
16 16
      */
17
-    protected $content = '';
17
+    protected $content='';
18 18
 
19 19
     /**
20 20
      * The main document which this embedment embedding into.
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
      *
29 29
      * @param \Htsl\Parser\Document $document
30 30
      */
31
-    final public function __construct(Document $document)
31
+    final public function __construct( Document $document )
32 32
     {
33
-        $this->document = $document;
33
+        $this->document=$document;
34 34
 
35 35
         $this->construct();
36 36
     }
@@ -59,5 +59,5 @@  discard block
 block discarded – undo
59 59
      *
60 60
      * @return \Htsl\Embedment\Contracts
61 61
      */
62
-    abstract public function parseLine(Line $line):self;
62
+    abstract public function parseLine( Line $line ):self;
63 63
 }
Please login to merge, or discard this patch.
libs/Embedment/JsEmbedment.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
     protected function construct()
16 16
     {
17
-        $this->content .= "\n";
17
+        $this->content.="\n";
18 18
     }
19 19
 
20 20
     /**
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      *
25 25
      * @return \Htsl\Embedment\Contracts
26 26
      */
27
-    public function parseLine(Line $line):parent
27
+    public function parseLine( Line $line ):parent
28 28
     {
29
-        $this->content .= $line->fullContent."\n";
29
+        $this->content.=$line->fullContent."\n";
30 30
 
31 31
         return $this;
32 32
     }
Please login to merge, or discard this patch.
libs/Embedment/TextEmbedment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
      *
17 17
      * @return \Htsl\Embedment\Contracts
18 18
      */
19
-    public function parseLine(Line $line):parent
19
+    public function parseLine( Line $line ):parent
20 20
     {
21
-        $this->content .= $line->fullContent."\n";
21
+        $this->content.=$line->fullContent."\n";
22 22
 
23 23
         return $this;
24 24
     }
Please login to merge, or discard this patch.
libs/Embedment/CssEmbedment.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
      *
17 17
      * @return \Htsl\Embedment\Contracts
18 18
      */
19
-    public function parseLine(Line $line):parent
19
+    public function parseLine( Line $line ):parent
20 20
     {
21
-        $this->content .= $line->content;
21
+        $this->content.=$line->content;
22 22
 
23 23
         return $this;
24 24
     }
Please login to merge, or discard this patch.
libs/Parser/Document.php 1 patch
Spacing   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -68,35 +68,35 @@  discard block
 block discarded – undo
68 68
      *
69 69
      * @var int
70 70
      */
71
-    private $level = 0;
71
+    private $level=0;
72 72
 
73 73
     /**
74 74
      * Section indent level.
75 75
      *
76 76
      * @var int
77 77
      */
78
-    private $sectionLevel = 0;
78
+    private $sectionLevel=0;
79 79
 
80 80
     /**
81 81
      * Opened nodes.
82 82
      *
83 83
      * @var [ Htsl\Parser\Node\Contracts\ANode, ]
84 84
      */
85
-    private $openedNodes = [];
85
+    private $openedNodes=[ ];
86 86
 
87 87
     /**
88 88
      * Current scopes.
89 89
      *
90 90
      * @var [ Htsl\Parser\Node\Contracts\ANode, ]
91 91
      */
92
-    private $scopes = [];
92
+    private $scopes=[ ];
93 93
 
94 94
     /**
95 95
      * Current line number.
96 96
      *
97 97
      * @var int
98 98
      */
99
-    private $lineNumber = 0;
99
+    private $lineNumber=0;
100 100
 
101 101
     /**
102 102
      * Current line.
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @var [ Htsl\Parser\Section, ]
112 112
      */
113
-    private $sections = [];
113
+    private $sections=[ ];
114 114
 
115 115
     /**
116 116
      * Whether the document is executed.
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
      * @param \Htsl\ReadingBuffer\Contracts\ABuffer $buffer
141 141
      * @param \Htsl\Parser\Document | null          $parent
142 142
      */
143
-    public function __construct(Htsl $htsl, Buffer $buffer, self $parent = null)
143
+    public function __construct( Htsl $htsl, Buffer $buffer, self $parent=null )
144 144
     {
145
-        $this->htsl = $htsl;
146
-        $this->buffer = $buffer;
145
+        $this->htsl=$htsl;
146
+        $this->buffer=$buffer;
147 147
 
148
-        if ($parent) {
149
-            $this->parent = $parent;
150
-            $this->docType = $parent->docType;
151
-            $this->indentation = $parent->indentation;
152
-        } else {
148
+        if( $parent ){
149
+            $this->parent=$parent;
150
+            $this->docType=$parent->docType;
151
+            $this->indentation=$parent->indentation;
152
+        }else{
153 153
             $this->parseFirstLine();
154 154
         }
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function execute():self
163 163
     {
164
-        if ($this->isExecuted) {
164
+        if( $this->isExecuted ){
165 165
             return $this;
166 166
         }
167 167
 
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      */
187 187
     protected function getContent():string
188 188
     {
189
-        if ($this->parent) {
189
+        if( $this->parent ){
190 190
             return $this->execute()->parent->getContent();
191
-        } else {
191
+        }else{
192 192
             return $this->execute()->content;
193 193
         }
194 194
     }
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
      */
201 201
     protected function getLine():Line
202 202
     {
203
-        do {
204
-            $line = $this->buffer->getLine();
205
-        } while ($line->isEmpty() && $line->hasMore());
203
+        do{
204
+            $line=$this->buffer->getLine();
205
+        }while( $line->isEmpty() && $line->hasMore() );
206 206
 
207 207
         return $line;
208 208
     }
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
      *
215 215
      * @return mixed
216 216
      */
217
-    public function getConfig(string ...$keys)
217
+    public function getConfig( string ...$keys )
218 218
     {
219 219
         return $this->htsl->getConfig(array_shift($keys), $this->docType, ...$keys);
220 220
     }
@@ -256,17 +256,17 @@  discard block
 block discarded – undo
256 256
      */
257 257
     protected function parseFirstLine():self
258 258
     {
259
-        $line = $this->getLine();
259
+        $line=$this->getLine();
260 260
 
261
-        if ('@' === $line->getChar(0)) {
261
+        if( '@'===$line->getChar(0) ){
262 262
             return $this->setExtending($line);
263 263
         }
264 264
 
265
-        $this->docType = $line->content;
266
-        $docTypeContent = $this->getConfig('doc_types') or $this->throw("DocType $this->docType is not supported");
265
+        $this->docType=$line->content;
266
+        $docTypeContent=$this->getConfig('doc_types') or $this->throw("DocType $this->docType is not supported");
267 267
 
268
-        $this->indentation = $this->htsl->getConfig('indentation', $this->docType) ?? (function ($scalarOrFalse) {
269
-            return is_scalar($scalarOrFalse) ? $scalarOrFalse : false;
268
+        $this->indentation=$this->htsl->getConfig('indentation', $this->docType) ?? (function( $scalarOrFalse ){
269
+            return is_scalar($scalarOrFalse)? $scalarOrFalse : false;
270 270
         })($this->htsl->getConfig('indentation'));
271 271
 
272 272
         $this->appendLine($docTypeContent);
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
      *
280 280
      * @param \Htsl\ReadingBuffer\Line $firstLine
281 281
      */
282
-    protected function setExtending(Line $firstLine):self
282
+    protected function setExtending( Line $firstLine ):self
283 283
     {
284
-        switch ($name = $firstLine->pregGet('/(?<=^@)[\w-:]+/')) {
284
+        switch( $name=$firstLine->pregGet('/(?<=^@)[\w-:]+/') ){
285 285
             default:{
286 286
                 $this->throw("The @$name is not supported.");
287 287
             }break;
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
      */
306 306
     protected function lineByLine():self
307 307
     {
308
-        while (($line = $this->getLine())->hasMore()) {
309
-            $this->lineNumber += 1;
308
+        while( ($line=$this->getLine())->hasMore() ){
309
+            $this->lineNumber+=1;
310 310
 
311
-            if ($this->embedment) {
311
+            if( $this->embedment ){
312 312
                 $this->embeddingParse($line);
313
-            } else {
313
+            }else{
314 314
                 $this->parseLine($line);
315 315
             }
316 316
         }
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
         $this->closeNodes($this->level);
321 321
 
322
-        $this->isExecuted = true;
322
+        $this->isExecuted=true;
323 323
 
324 324
         return $this;
325 325
     }
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
      *
332 332
      * @return \Htsl\Parser\Document
333 333
      */
334
-    protected function embeddingParse(Line $line):self
334
+    protected function embeddingParse( Line $line ):self
335 335
     {
336
-        if ($line->content === '<}') {
336
+        if( $line->content==='<}' ){
337 337
             $this->breakEmbedding();
338
-        } else {
338
+        }else{
339 339
             $this->embedment->parseLine($line->getSubIndentLine());
340 340
         }
341 341
 
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
      *
350 350
      * @return \Htsl\Parser\Document
351 351
      */
352
-    protected function startEmbedding(string $embedType):self
352
+    protected function startEmbedding( string $embedType ):self
353 353
     {
354
-        $embedmentClass = '\\Htsl\\Embedment\\'.ucfirst($embedType).'Embedment';
354
+        $embedmentClass='\\Htsl\\Embedment\\'.ucfirst($embedType).'Embedment';
355 355
         class_exists($embedmentClass) or $this->throw("Embed type $embedType not exists.");
356 356
 
357
-        $this->embedment = new $embedmentClass($this);
357
+        $this->embedment=new $embedmentClass($this);
358 358
 
359 359
         return $this;
360 360
     }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
     public function breakEmbedding():self
368 368
     {
369 369
         $this->append($this->embedment->getContent());
370
-        $this->embedment = null;
370
+        $this->embedment=null;
371 371
 
372 372
         return $this;
373 373
     }
@@ -379,19 +379,19 @@  discard block
 block discarded – undo
379 379
      *
380 380
      * @return \Htsl\Parser\Document
381 381
      */
382
-    protected function parseLine(Line $line):self
382
+    protected function parseLine( Line $line ):self
383 383
     {
384
-        $this->currentLine = $line;
384
+        $this->currentLine=$line;
385 385
         $this->setLevel($line->getIndentLevel());
386 386
 
387
-        switch ($line->getChar(0)) {
387
+        switch( $line->getChar(0) ){
388 388
             default:{
389 389
                 $this->parseStringLine($line);
390 390
             }break;
391 391
             case '`':{
392
-                if ('=' === $line->getChar(1)) {
392
+                if( '='===$line->getChar(1) ){
393 393
                     $this->parseExpressionHtmlLine($line);
394
-                } else {
394
+                }else{
395 395
                     $this->parseHtmlLine($line);
396 396
                 }
397 397
             }break;
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
      *
423 423
      * @return \Htsl\Parser\Document
424 424
      */
425
-    protected function parseHtmlLine(Line $line):self
425
+    protected function parseHtmlLine( Line $line ):self
426 426
     {
427
-        $node = new StringNode($this, $line);
427
+        $node=new StringNode($this, $line);
428 428
 
429 429
         $this->openNode($node);
430 430
 
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
      *
441 441
      * @return \Htsl\Parser\Document
442 442
      */
443
-    protected function parseStringLine(Line $line):self
443
+    protected function parseStringLine( Line $line ):self
444 444
     {
445
-        $node = new StringNode($this, $line);
445
+        $node=new StringNode($this, $line);
446 446
 
447 447
         $this->openNode($node);
448 448
 
@@ -458,14 +458,14 @@  discard block
 block discarded – undo
458 458
      *
459 459
      * @return \Htsl\Parser\Document
460 460
      */
461
-    protected function parseExpressionLine(Line $line):self
461
+    protected function parseExpressionLine( Line $line ):self
462 462
     {
463
-        $node = new StringNode($this, $line);
463
+        $node=new StringNode($this, $line);
464 464
 
465 465
         $this->openNode($node);
466 466
 
467
-        $content = $line->slice(1);
468
-        $ent_flag = $this->htsl->getConfig('ENT_flags', $this->docType);
467
+        $content=$line->slice(1);
468
+        $ent_flag=$this->htsl->getConfig('ENT_flags', $this->docType);
469 469
 
470 470
         $this->appendLine("<?=htmlentities($content,'$ent_flag','UTF-8',false);?>");
471 471
 
@@ -479,13 +479,13 @@  discard block
 block discarded – undo
479 479
      *
480 480
      * @return \Htsl\Parser\Document
481 481
      */
482
-    protected function parseExpressionHtmlLine(Line $line):self
482
+    protected function parseExpressionHtmlLine( Line $line ):self
483 483
     {
484
-        $node = new StringNode($this, $line);
484
+        $node=new StringNode($this, $line);
485 485
 
486 486
         $this->openNode($node);
487 487
 
488
-        $content = $line->slice(1);
488
+        $content=$line->slice(1);
489 489
 
490 490
         $this->appendLine("<?$content?>");
491 491
 
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
      *
500 500
      * @return \Htsl\Parser\Document
501 501
      */
502
-    protected function parseCommentLine(Line $line):self
502
+    protected function parseCommentLine( Line $line ):self
503 503
     {
504
-        $node = new CommentNode($this, $line);
504
+        $node=new CommentNode($this, $line);
505 505
 
506 506
         $this->openNode($node);
507 507
 
@@ -517,9 +517,9 @@  discard block
 block discarded – undo
517 517
      *
518 518
      * @return \Htsl\Parser\Document
519 519
      */
520
-    protected function parseTagLine(Line $line):self
520
+    protected function parseTagLine( Line $line ):self
521 521
     {
522
-        $tag = new TagNode($this, $line);
522
+        $tag=new TagNode($this, $line);
523 523
 
524 524
         $this->appendLine($tag->open());
525 525
 
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
      *
538 538
      * @return \Htsl\Parser\Document
539 539
      */
540
-    protected function parseControlLine(Line $line):self
540
+    protected function parseControlLine( Line $line ):self
541 541
     {
542
-        $controlStructure = new ControlNode($this, $line);
542
+        $controlStructure=new ControlNode($this, $line);
543 543
 
544 544
         $this->appendLine($controlStructure->open());
545 545
 
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
      *
556 556
      * @return \Htsl\Parser\Document
557 557
      */
558
-    protected function parseDocControlLine(Line $line):self
558
+    protected function parseDocControlLine( Line $line ):self
559 559
     {
560
-        switch ($name = $line->pregGet('/(?<=^@)[\w-:]+/')) {
560
+        switch( $name=$line->pregGet('/(?<=^@)[\w-:]+/') ){
561 561
             default:{
562 562
                 $this->throw("The @$name is not supported.");
563 563
             }break;
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
      *
586 586
      * @return \Htsl\Parser\Document
587 587
      */
588
-    protected function extend(string $fileName):self
588
+    protected function extend( string $fileName ):self
589 589
     {
590
-        $this->parent = new static($this->htsl, $this->buffer->goSide($fileName), null, $this->indentation);
590
+        $this->parent=new static($this->htsl, $this->buffer->goSide($fileName), null, $this->indentation);
591 591
 
592
-        $this->docType = $this->parent->docType;
593
-        $this->indentation = $this->parent->indentation;
592
+        $this->docType=$this->parent->docType;
593
+        $this->indentation=$this->parent->indentation;
594 594
 
595 595
         return $this;
596 596
     }
@@ -604,13 +604,13 @@  discard block
 block discarded – undo
604 604
      */
605 605
     protected function include(Line $line):self
606 606
     {
607
-        $inclued = (new static($this->htsl, $this->buffer->goSide($line->pregGet('/(?<=\( ).*(?= \))/')), $this, $this->indentation))->execute()->content;
607
+        $inclued=(new static($this->htsl, $this->buffer->goSide($line->pregGet('/(?<=\( ).*(?= \))/')), $this, $this->indentation))->execute()->content;
608 608
 
609
-        if (false !== $this->indentation) {
610
-            $inclued = preg_replace('/(?<=^|\\n)(?!$)/', str_repeat($this->indentation, $this->level - $this->sectionLevel), $inclued);
609
+        if( false!==$this->indentation ){
610
+            $inclued=preg_replace('/(?<=^|\\n)(?!$)/', str_repeat($this->indentation, $this->level-$this->sectionLevel), $inclued);
611 611
         }
612 612
 
613
-        $node = new StringNode($this, $line);
613
+        $node=new StringNode($this, $line);
614 614
 
615 615
         $this->openNode($node);
616 616
 
@@ -626,9 +626,9 @@  discard block
 block discarded – undo
626 626
      *
627 627
      * @return \Htsl\Parser\Document
628 628
      */
629
-    protected function defineSection(Line $line):self
629
+    protected function defineSection( Line $line ):self
630 630
     {
631
-        $node = new SectionNode($this, $line);
631
+        $node=new SectionNode($this, $line);
632 632
 
633 633
         $node->open();
634 634
 
@@ -644,24 +644,24 @@  discard block
 block discarded – undo
644 644
      *
645 645
      * @return \Htsl\Parser\Document
646 646
      */
647
-    protected function showSection(Line $line):self
647
+    protected function showSection( Line $line ):self
648 648
     {
649
-        $sectionName = $line->pregGet('/(?<=\( ).*(?= \))/');
649
+        $sectionName=$line->pregGet('/(?<=\( ).*(?= \))/');
650 650
 
651
-        if (!isset($this->sections[$sectionName])) {
651
+        if( !isset($this->sections[ $sectionName ]) ){
652 652
             $this->openNode(new StringNode($this, $line));
653 653
 
654 654
             return $this;
655 655
         }
656
-        $content = $this->sections[$sectionName]->content;
656
+        $content=$this->sections[ $sectionName ]->content;
657 657
 
658
-        if (false !== $this->indentation) {
659
-            $content = preg_replace('/(?<=^|\\n)(?!$)/', str_repeat($this->indentation, $this->level), $content);
658
+        if( false!==$this->indentation ){
659
+            $content=preg_replace('/(?<=^|\\n)(?!$)/', str_repeat($this->indentation, $this->level), $content);
660 660
         }
661 661
 
662 662
         $this->append($content);
663 663
 
664
-        $node = new NamelessSectionNode($this, $line);
664
+        $node=new NamelessSectionNode($this, $line);
665 665
 
666 666
         $node->open();
667 667
 
@@ -675,30 +675,30 @@  discard block
 block discarded – undo
675 675
      *
676 676
      * @param Section | null $section
677 677
      */
678
-    public function setSection(Section $section = null):self
678
+    public function setSection( Section $section=null ):self
679 679
     {
680
-        if (!$section) {
681
-            $this->sectionLevel = 0;
682
-            $this->currentSection = null;
680
+        if( !$section ){
681
+            $this->sectionLevel=0;
682
+            $this->currentSection=null;
683 683
 
684 684
             return $this;
685 685
         }
686 686
 
687
-        if ($this->currentSection) {
687
+        if( $this->currentSection ){
688 688
             $this->throw('Nesting definition of section is forbidden.');
689 689
         }
690 690
 
691
-        if (isset($this->parent->sections[$section->name])) {
691
+        if( isset($this->parent->sections[ $section->name ]) ){
692 692
             $this->throw("Section $sectionName already defined.");
693 693
         }
694 694
 
695
-        $this->currentSection = $section;
695
+        $this->currentSection=$section;
696 696
 
697
-        if ($section->name) {
698
-            $this->parent->sections[$section->name] = $section;
697
+        if( $section->name ){
698
+            $this->parent->sections[ $section->name ]=$section;
699 699
         }
700 700
 
701
-        $this->sectionLevel = $this->level + 1;
701
+        $this->sectionLevel=$this->level+1;
702 702
 
703 703
         return $this;
704 704
     }
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
      */
711 711
     protected function bubbleSections():self
712 712
     {
713
-        if ($this->parent) {
714
-            foreach ($this->sections as $name => $section) {
715
-                if (!isset($this->parent->sections[$name])) {
716
-                    $this->parent->sections[$name] = $section;
713
+        if( $this->parent ){
714
+            foreach( $this->sections as $name => $section ){
715
+                if( !isset($this->parent->sections[ $name ]) ){
716
+                    $this->parent->sections[ $name ]=$section;
717 717
                 }
718 718
             }
719 719
         }
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
      *
729 729
      * @return string
730 730
      */
731
-    public function htmlEntities(string $input):string
731
+    public function htmlEntities( string $input ):string
732 732
     {
733 733
         return htmlentities($input, $this->htsl->getConfig('ENT_flags', $this->docType), 'UTF-8', false);
734 734
     }
@@ -738,15 +738,15 @@  discard block
 block discarded – undo
738 738
      *
739 739
      * @param int $level
740 740
      */
741
-    protected function setLevel(int $level):self
741
+    protected function setLevel( int $level ):self
742 742
     {
743
-        $level -= $this->level;
743
+        $level-=$this->level;
744 744
 
745
-        if ($level <= 0) {
745
+        if( $level<=0 ){
746 746
             $this->closeNodes(-$level);
747
-        } elseif ($level == 1) {
748
-            $this->level += 1;
749
-        } else {
747
+        } elseif( $level==1 ){
748
+            $this->level+=1;
749
+        }else{
750 750
             $this->throw('Indent error.');
751 751
         }
752 752
 
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
      *
761 761
      * @return \Htsl\Parser\Document
762 762
      */
763
-    protected function openNode(Node $node):self
763
+    protected function openNode( Node $node ):self
764 764
     {
765 765
         array_push($this->openedNodes, $node);
766 766
 
@@ -776,20 +776,20 @@  discard block
 block discarded – undo
776 776
      *
777 777
      * @return \Htsl\Parser\Document
778 778
      */
779
-    protected function closeNodes(int $level = 0):self
779
+    protected function closeNodes( int $level=0 ):self
780 780
     {
781
-        if (empty($this->openedNodes)) {
781
+        if( empty($this->openedNodes) ){
782 782
             return $this;
783 783
         }
784 784
 
785
-        while ($level-- >= 0) {
786
-            $node = array_pop($this->openedNodes);
785
+        while( $level-->=0 ){
786
+            $node=array_pop($this->openedNodes);
787 787
 
788 788
             $node->scope and $this->removeScope($node);
789 789
 
790
-            $closer = $node->close($this->currentLine) and $this->appendLine($closer);
790
+            $closer=$node->close($this->currentLine) and $this->appendLine($closer);
791 791
 
792
-            $this->level -= $level >= 0 ? 1 : 0;
792
+            $this->level-=$level>=0? 1 : 0;
793 793
         }
794 794
 
795 795
         return $this;
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
      *
801 801
      * @param \Htsl\Parser\Node\Contracts\ANode $scope
802 802
      */
803
-    protected function setScope(Node $scope):int
803
+    protected function setScope( Node $scope ):int
804 804
     {
805 805
         return array_unshift($this->scopes, $scope);
806 806
     }
@@ -812,7 +812,7 @@  discard block
 block discarded – undo
812 812
      */
813 813
     public function getScope()
814 814
     {
815
-        return $this->scopes[0] ?? null;
815
+        return $this->scopes[ 0 ] ?? null;
816 816
     }
817 817
 
818 818
     /**
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
      *
823 823
      * @return \Htsl\Parser\Document
824 824
      */
825
-    protected function removeScope(Node $scope):self
825
+    protected function removeScope( Node $scope ):self
826 826
     {
827
-        if ($scope !== array_shift($this->scopes)) {
827
+        if( $scope!==array_shift($this->scopes) ){
828 828
             $this->throw('Scope nesting error');
829 829
         }
830 830
 
@@ -838,10 +838,10 @@  discard block
 block discarded – undo
838 838
      *
839 839
      * @return \Htsl\Parser\Document
840 840
      */
841
-    protected function appendLine(string $content):self
841
+    protected function appendLine( string $content ):self
842 842
     {
843
-        if (false !== $this->indentation) {
844
-            $content = str_repeat($this->indentation, $this->level - $this->sectionLevel).$content."\n";
843
+        if( false!==$this->indentation ){
844
+            $content=str_repeat($this->indentation, $this->level-$this->sectionLevel).$content."\n";
845 845
         }
846 846
 
847 847
         return $this->append($content);
@@ -854,12 +854,12 @@  discard block
 block discarded – undo
854 854
      *
855 855
      * @return \Htsl\Parser\Document
856 856
      */
857
-    protected function append(string $content):self
857
+    protected function append( string $content ):self
858 858
     {
859
-        if ($this->currentSection) {
859
+        if( $this->currentSection ){
860 860
             $this->currentSection->append($content);
861
-        } else {
862
-            $this->content .= $content;
861
+        }else{
862
+            $this->content.=$content;
863 863
         }
864 864
 
865 865
         return $this;
Please login to merge, or discard this patch.
libs/Parser/Node/TagNode.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @var array
31 31
      */
32
-    private $attributes = [];
32
+    private $attributes=[ ];
33 33
 
34 34
     /**
35 35
      * Real constructor.
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
      */
39 39
     protected function construct():parent
40 40
     {
41
-        $name = $this->line->pregGet('/(?<=^-)[\w-:]+/');
42
-        $this->name = $name;
41
+        $name=$this->line->pregGet('/(?<=^-)[\w-:]+/');
42
+        $this->name=$name;
43 43
 
44 44
         $this->loadConfig($name, $this->document);
45 45
 
46
-        $this->tagName = $this->config['name'] ?? $name;
47
-        $this->isEmpty = $this->line->getChar(-1) === '/' || $this->document->getConfig('empty_tags', $this->tagName);
48
-        isset($this->config['default_attributes']) and array_walk($this->config['default_attributes'], function ($value, $key) {
46
+        $this->tagName=$this->config[ 'name' ] ?? $name;
47
+        $this->isEmpty=$this->line->getChar(-1)==='/' || $this->document->getConfig('empty_tags', $this->tagName);
48
+        isset($this->config[ 'default_attributes' ]) and array_walk($this->config[ 'default_attributes' ], function( $value, $key ){
49 49
             $this->setAttribute($key, $value);
50 50
         });
51 51
 
@@ -59,37 +59,37 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function open():string
61 61
     {
62
-        if (isset($this->config['opener'])) {
63
-            return $this->config['opener'];
62
+        if( isset($this->config[ 'opener' ]) ){
63
+            return $this->config[ 'opener' ];
64 64
         }
65 65
 
66
-        if (isset($this->config['params'])) {
66
+        if( isset($this->config[ 'params' ]) ){
67 67
             $this->parseParams();
68 68
         }
69 69
 
70
-        if (isset($this->config['name_value'])) {
70
+        if( isset($this->config[ 'name_value' ]) ){
71 71
             $this->parseNameValue();
72 72
         }
73 73
 
74
-        if (isset($this->config['link'])) {
74
+        if( isset($this->config[ 'link' ]) ){
75 75
             $this->parseLink();
76 76
         }
77 77
 
78
-        if (isset($this->config['target'])) {
78
+        if( isset($this->config[ 'target' ]) ){
79 79
             $this->parseTarget();
80 80
         }
81 81
 
82
-        if (isset($this->config['alt'])) {
82
+        if( isset($this->config[ 'alt' ]) ){
83 83
             $this->parseAlt();
84 84
         }
85 85
 
86 86
         $this->parseCommonAttributes();
87 87
 
88
-        if (isset($this->config['in_scope']) && isset($this->config['scope_function']) && is_callable($this->config['scope_function'])) {
89
-            $this->config['scope_function']->call($this, $this->document->scope);
88
+        if( isset($this->config[ 'in_scope' ]) && isset($this->config[ 'scope_function' ]) && is_callable($this->config[ 'scope_function' ]) ){
89
+            $this->config[ 'scope_function' ]->call($this, $this->document->scope);
90 90
         }
91 91
 
92
-        $finisher = $this->isEmpty ? ' />' : '>';
92
+        $finisher=$this->isEmpty? ' />' : '>';
93 93
 
94 94
         return "<{$this->tagName}{$this->attributesString}{$finisher}";
95 95
     }
@@ -101,9 +101,9 @@  discard block
 block discarded – undo
101 101
      *
102 102
      * @return string
103 103
      */
104
-    public function close(Line $Line):string
104
+    public function close( Line $Line ):string
105 105
     {
106
-        return $this->isEmpty ? '' : $this->config['closer'] ?? "</{$this->tagName}>";
106
+        return $this->isEmpty? '' : $this->config[ 'closer' ] ?? "</{$this->tagName}>";
107 107
     }
108 108
 
109 109
     /**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function getEmbed():string
115 115
     {
116
-        return $this->config['embedding'] ?? '';
116
+        return $this->config[ 'embedding' ] ?? '';
117 117
     }
118 118
 
119 119
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function getScope()
125 125
     {
126
-        return $this->config['scope'] ?? null;
126
+        return $this->config[ 'scope' ] ?? null;
127 127
     }
128 128
 
129 129
     /**
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function parseParams():self
135 135
     {
136
-        $params = preg_split('/(?<!\\\\)\\|/', $this->line->pregGet('/^-[\w-:]+\((.*?)\)(?= |(\\{>)?$)/', 1));
136
+        $params=preg_split('/(?<!\\\\)\\|/', $this->line->pregGet('/^-[\w-:]+\((.*?)\)(?= |(\\{>)?$)/', 1));
137 137
 
138
-        if (($m = count($params)) != ($n = count($this->config['params']))) {
138
+        if( ($m=count($params))!=($n=count($this->config[ 'params' ])) ){
139 139
             $this->document->throw("Tag $this->name has $n parameters $m given.");
140 140
         }
141 141
 
142
-        array_map(function ($key, $value) {
142
+        array_map(function( $key, $value ){
143 143
             return $this->setAttribute($key, str_replace('\\|', '|', $value));
144
-        }, $this->config['params'], $params);
144
+        }, $this->config[ 'params' ], $params);
145 145
 
146 146
         return $this;
147 147
     }
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
      */
154 154
     protected function parseNameValue():self
155 155
     {
156
-        $params = $this->line->pregGet('/ <(.*?)>(?= |$)/', 1)
157
-         and $params = preg_split('/(?<!\\\\)\\|/', $params)
158
-          and array_map(function ($key, $value) {
159
-              return isset($key) && isset($value) ? $this->setAttribute($key, $this->checkExpression(str_replace('\\|', '|', $value))) : '';
160
-          }, $this->config['name_value'], $params);
156
+        $params=$this->line->pregGet('/ <(.*?)>(?= |$)/', 1)
157
+         and $params=preg_split('/(?<!\\\\)\\|/', $params)
158
+          and array_map(function( $key, $value ){
159
+              return isset($key) && isset($value)? $this->setAttribute($key, $this->checkExpression(str_replace('\\|', '|', $value))) : '';
160
+          }, $this->config[ 'name_value' ], $params);
161 161
 
162 162
         return $this;
163 163
     }
@@ -169,17 +169,17 @@  discard block
 block discarded – undo
169 169
      */
170 170
     protected function parseLink():self
171 171
     {
172
-        $link = $this->line->pregGet('/ @((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1);
173
-
174
-        if (strlen($link)) {
175
-            if (isset($this->config['target']) && ':' === $link[0]) {
176
-                $this->setAttribute($this->config['link'], 'javascript'.$link);
177
-            } elseif ('//' === ($firstTwoLetters = substr($link, 0, 2))) {
178
-                $this->setAttribute($this->config['link'], 'http:'.$link);
179
-            } elseif ('\\\\' === $firstTwoLetters) {
180
-                $this->setAttribute($this->config['link'], 'https://'.substr($link, 2));
181
-            } else {
182
-                $this->setAttribute($this->config['link'], $this->checkExpression($link));
172
+        $link=$this->line->pregGet('/ @((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1);
173
+
174
+        if( strlen($link) ){
175
+            if( isset($this->config[ 'target' ]) && ':'===$link[ 0 ] ){
176
+                $this->setAttribute($this->config[ 'link' ], 'javascript'.$link);
177
+            } elseif( '//'===($firstTwoLetters=substr($link, 0, 2)) ){
178
+                $this->setAttribute($this->config[ 'link' ], 'http:'.$link);
179
+            } elseif( '\\\\'===$firstTwoLetters ){
180
+                $this->setAttribute($this->config[ 'link' ], 'https://'.substr($link, 2));
181
+            }else{
182
+                $this->setAttribute($this->config[ 'link' ], $this->checkExpression($link));
183 183
             }
184 184
         }
185 185
 
@@ -193,10 +193,10 @@  discard block
 block discarded – undo
193 193
      */
194 194
     protected function parseTarget():self
195 195
     {
196
-        $target = $this->line->pregGet('/ >((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1);
196
+        $target=$this->line->pregGet('/ >((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1);
197 197
 
198
-        if (strlen($target)) {
199
-            $this->setAttribute($this->config['target'], $this->checkExpression($target));
198
+        if( strlen($target) ){
199
+            $this->setAttribute($this->config[ 'target' ], $this->checkExpression($target));
200 200
         }
201 201
 
202 202
         return $this;
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
      */
210 210
     protected function parseAlt():self
211 211
     {
212
-        $alt = $this->line->pregGet('/ _((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1);
212
+        $alt=$this->line->pregGet('/ _((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1);
213 213
 
214
-        if (strlen($alt)) {
215
-            $this->setAttribute($this->config['alt'], $this->checkExpression($alt));
214
+        if( strlen($alt) ){
215
+            $this->setAttribute($this->config[ 'alt' ], $this->checkExpression($alt));
216 216
         }
217 217
 
218 218
         return $this;
@@ -225,33 +225,33 @@  discard block
 block discarded – undo
225 225
      */
226 226
     protected function parseCommonAttributes():string
227 227
     {
228
-        $attributes = '';
228
+        $attributes='';
229 229
 
230
-        $id = $this->line->pregGet('/ #([^ ]+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1)
230
+        $id=$this->line->pregGet('/ #([^ ]+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1)
231 231
          and $this->setAttribute('id', $id);
232 232
 
233
-        $classes = $this->line->pregGet('/ \.[^ ]+(?= |$)/')
233
+        $classes=$this->line->pregGet('/ \.[^ ]+(?= |$)/')
234 234
          and preg_match_all('/\.((?(?!\()[^.]+|(?<exp>\((?:[^()]+|(?&exp)?)+?\))))/', $classes, $matches)
235
-          and $classes = implode(' ', array_filter(array_map(function ($className) {
235
+          and $classes=implode(' ', array_filter(array_map(function( $className ){
236 236
               return $this->checkExpression($className);
237
-          }, $matches[1])))
237
+          }, $matches[ 1 ])))
238 238
            and $this->setAttribute('class', $classes);
239 239
 
240
-        $title = $this->line->pregGet('/ \^((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1)
240
+        $title=$this->line->pregGet('/ \^((?!\()(?:[^ ]| (?=[a-zA-Z0-9]))+|(?<exp>\((?:[^()]+|(?&exp)?)+?\)))(?= |$)/', 1)
241 241
          and $this->setAttribute('title', $title);
242 242
 
243
-        $style = $this->line->pregGet('/ \[([^\]]+;)(?=\]( |$))/', 1)
243
+        $style=$this->line->pregGet('/ \[([^\]]+;)(?=\]( |$))/', 1)
244 244
          and $this->setAttribute('style', $style);
245 245
 
246
-        $eventListeners = $this->line->pregMap('/ %(\w+)\{>(.*?)<\}(?= |$)/', function ($string, $name, $code) {
246
+        $eventListeners=$this->line->pregMap('/ %(\w+)\{>(.*?)<\}(?= |$)/', function( $string, $name, $code ){
247 247
             $this->setAttribute('on'.$name, str_replace('"', '&quot;', $code));
248 248
         })
249 249
          and implode('', $eventListeners);
250 250
 
251
-        $other = $this->line->pregGet('/(?<=\{).*?(?=;\}( |$))/')
252
-         and array_map(function ($keyValue) {
253
-             preg_replace_callback('/^([\w-:]+)(?:\?(.+?))?(?:\=(.*))?$/', function ($matches) {
254
-                 $this->setAttribute($matches[1], ($matches[3] ?? $matches[1]) ?: $matches[1], $matches[2] ?? null);
251
+        $other=$this->line->pregGet('/(?<=\{).*?(?=;\}( |$))/')
252
+         and array_map(function( $keyValue ){
253
+             preg_replace_callback('/^([\w-:]+)(?:\?(.+?))?(?:\=(.*))?$/', function( $matches ){
254
+                 $this->setAttribute($matches[ 1 ], ($matches[ 3 ] ?? $matches[ 1 ])?: $matches[ 1 ], $matches[ 2 ] ?? null);
255 255
              }, $keyValue);
256 256
          }, explode(';', $other));
257 257
 
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
      *
266 266
      * @return string
267 267
      */
268
-    protected function checkExpression(string $value):string
268
+    protected function checkExpression( string $value ):string
269 269
     {
270
-        return preg_match('/^\(.*\)$/', $value) ? '<?='.substr($value, 1, -1).';?>' : str_replace('"', '&quot;', $value);
270
+        return preg_match('/^\(.*\)$/', $value)? '<?='.substr($value, 1, -1).';?>' : str_replace('"', '&quot;', $value);
271 271
     }
272 272
 
273 273
     /**
@@ -279,11 +279,11 @@  discard block
 block discarded – undo
279 279
     {
280 280
         ksort($this->attributes);
281 281
 
282
-        return implode('', array_map(static function (string $key, array $data) {
283
-            return isset($data['condition']) && strlen($data['condition']) ?
284
-                "<?php if( {$data['condition']} ){?> $key=\"{$data['value']}\"<?php }?>"
282
+        return implode('', array_map(static function( string $key, array $data ){
283
+            return isset($data[ 'condition' ]) && strlen($data[ 'condition' ])?
284
+                "<?php if( {$data[ 'condition' ]} ){?> $key=\"{$data[ 'value' ]}\"<?php }?>"
285 285
                 :
286
-                " $key=\"{$data['value']}\"";
286
+                " $key=\"{$data[ 'value' ]}\"";
287 287
         }, array_keys($this->attributes), $this->attributes));
288 288
     }
289 289
 
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
      * @param string      $value     Attribute value
295 295
      * @param string|null $condition Optional condition, If given, attribute will seted only when condition is true.
296 296
      */
297
-    protected function setAttribute(string $key, string $value, string $condition = null):self
297
+    protected function setAttribute( string $key, string $value, string $condition=null ):self
298 298
     {
299
-        if (isset($this->attributes[$key])) {
299
+        if( isset($this->attributes[ $key ]) ){
300 300
             $this->document->throw("Attribute $key of $this->name cannot redeclare.");
301 301
         }
302 302
 
303
-        $this->attributes[$key] = [
303
+        $this->attributes[ $key ]=[
304 304
             'value'     => $value,
305 305
             'condition' => $condition,
306 306
         ];
@@ -319,9 +319,9 @@  discard block
 block discarded – undo
319 319
      *
320 320
      * @return bool
321 321
      */
322
-    public function offsetExists($offset):bool
322
+    public function offsetExists( $offset ):bool
323 323
     {
324
-        return isset($this->attributes[$offset]);
324
+        return isset($this->attributes[ $offset ]);
325 325
     }
326 326
 
327 327
     /**
@@ -331,9 +331,9 @@  discard block
 block discarded – undo
331 331
      *
332 332
      * @return mixed
333 333
      */
334
-    public function offsetGet($offset)
334
+    public function offsetGet( $offset )
335 335
     {
336
-        return $this->attributes[$offset] ?? null;
336
+        return $this->attributes[ $offset ] ?? null;
337 337
     }
338 338
 
339 339
     /**
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
      * @param mixed $offset
343 343
      * @param mixed $value
344 344
      */
345
-    public function offsetSet($offset, $value)
345
+    public function offsetSet( $offset, $value )
346 346
     {
347 347
         $this->setAttribute($offset, $value);
348 348
     }
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
      *
353 353
      * @param mixed $offset
354 354
      */
355
-    public function offsetUnset($offset)
355
+    public function offsetUnset( $offset )
356 356
     {
357
-        if (isset($this->attributes[$offset])) {
358
-            unset($this->attributes[$offset]);
357
+        if( isset($this->attributes[ $offset ]) ){
358
+            unset($this->attributes[ $offset ]);
359 359
         }
360 360
     }
361 361
 }
Please login to merge, or discard this patch.
libs/Parser/Node/NamelessSectionNode.php 1 patch
Spacing   +2 added lines, -2 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->name = null;
27
+        $this->name=null;
28 28
 
29 29
         return $this;
30 30
     }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @return string
50 50
      */
51
-    public function close(Line $closerLine):string
51
+    public function close( Line $closerLine ):string
52 52
     {
53 53
         $this->document->setSection(null);
54 54
 
Please login to merge, or discard this patch.