@@ -20,10 +20,16 @@ |
||
20 | 20 | 'case_separator', 'optional_comma' |
21 | 21 | )); |
22 | 22 | |
23 | +/** |
|
24 | + * @param string $regex |
|
25 | + */ |
|
23 | 26 | function regex($regex) { |
24 | 27 | return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; |
25 | 28 | } |
26 | 29 | |
30 | +/** |
|
31 | + * @param string $regex |
|
32 | + */ |
|
27 | 33 | function magicSplit($regex, $string) { |
28 | 34 | $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); |
29 | 35 |
@@ -175,6 +175,9 @@ discard block |
||
175 | 175 | ); |
176 | 176 | } |
177 | 177 | |
178 | +/** |
|
179 | + * @param integer $num |
|
180 | + */ |
|
178 | 181 | function assertArgs($num, $args, $name) { |
179 | 182 | if ($num != count($args)) { |
180 | 183 | die('Wrong argument count for ' . $name . '().'); |
@@ -203,10 +206,16 @@ discard block |
||
203 | 206 | /// Regex helper functions /// |
204 | 207 | ////////////////////////////// |
205 | 208 | |
209 | +/** |
|
210 | + * @param string $regex |
|
211 | + */ |
|
206 | 212 | function regex($regex) { |
207 | 213 | return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; |
208 | 214 | } |
209 | 215 | |
216 | +/** |
|
217 | + * @param string $regex |
|
218 | + */ |
|
210 | 219 | function magicSplit($regex, $string) { |
211 | 220 | $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); |
212 | 221 |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | assertArgs(2, $args, $name); |
139 | 139 | |
140 | 140 | return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); }' |
141 | - . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; |
|
141 | + . ' else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }'; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | if ('toArray' == $name) { |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | assertArgs(3, $args, $name); |
158 | 158 | |
159 | 159 | return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
160 | - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; |
|
160 | + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, ' . $args[1] . ', ' . $args[2] . '); } }'; |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | if ('parseEncapsedDoc' == $name) { |
164 | 164 | assertArgs(2, $args, $name); |
165 | 165 | |
166 | 166 | return 'foreach (' . $args[0] . ' as $s) { if ($s instanceof Node\Scalar\EncapsedStringPart) {' |
167 | - . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, ' . $args[1] . '); } }' |
|
168 | - . ' $s->value = preg_replace(\'~(\r\n|\n|\r)\z~\', \'\', $s->value);' |
|
169 | - . ' if (\'\' === $s->value) array_pop(' . $args[0] . ');'; |
|
167 | + . ' $s->value = Node\Scalar\String_::parseEscapeSequences($s->value, null, ' . $args[1] . '); } }' |
|
168 | + . ' $s->value = preg_replace(\'~(\r\n|\n|\r)\z~\', \'\', $s->value);' |
|
169 | + . ' if (\'\' === $s->value) array_pop(' . $args[0] . ');'; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | return $matches[0]; |
@@ -110,6 +110,9 @@ |
||
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
113 | + /** |
|
114 | + * @param Name $type |
|
115 | + */ |
|
113 | 116 | protected function addAlias(Stmt\UseUse $use, $type, Name $prefix = null) { |
114 | 117 | // Add prefix for group uses |
115 | 118 | $name = $prefix ? Name::concat($prefix, $use->name) : $use->name; |
@@ -51,6 +51,9 @@ |
||
51 | 51 | return $this->errors; |
52 | 52 | } |
53 | 53 | |
54 | + /** |
|
55 | + * @param string $code |
|
56 | + */ |
|
54 | 57 | private function tryParse(Parser $parser, $code) { |
55 | 58 | $stmts = null; |
56 | 59 | $error = null; |
@@ -534,6 +534,9 @@ discard block |
||
534 | 534 | . ($node->name->getLast() !== $node->alias ? ' as ' . $node->alias : ''); |
535 | 535 | } |
536 | 536 | |
537 | + /** |
|
538 | + * @param integer $type |
|
539 | + */ |
|
537 | 540 | private function pUseType($type) { |
538 | 541 | return $type === Stmt\Use_::TYPE_FUNCTION ? 'function ' |
539 | 542 | : ($type === Stmt\Use_::TYPE_CONSTANT ? 'const ' : ''); |
@@ -744,6 +747,9 @@ discard block |
||
744 | 747 | return is_string($node) ? $node : $this->p($node); |
745 | 748 | } |
746 | 749 | |
750 | + /** |
|
751 | + * @param string $afterClassToken |
|
752 | + */ |
|
747 | 753 | protected function pClassCommon(Stmt\Class_ $node, $afterClassToken) { |
748 | 754 | return $this->pModifiers($node->type) |
749 | 755 | . 'class' . $afterClassToken |
@@ -760,6 +766,9 @@ discard block |
||
760 | 766 | } |
761 | 767 | } |
762 | 768 | |
769 | + /** |
|
770 | + * @param integer $modifiers |
|
771 | + */ |
|
763 | 772 | protected function pModifiers($modifiers) { |
764 | 773 | return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') |
765 | 774 | . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') |
@@ -769,6 +778,9 @@ discard block |
||
769 | 778 | . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : ''); |
770 | 779 | } |
771 | 780 | |
781 | + /** |
|
782 | + * @param string $quote |
|
783 | + */ |
|
772 | 784 | protected function pEncapsList(array $encapsList, $quote) { |
773 | 785 | $return = ''; |
774 | 786 | foreach ($encapsList as $element) { |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | return ($node->static ? 'static ' : '') |
464 | 464 | . 'function ' . ($node->byRef ? '&' : '') |
465 | 465 | . '(' . $this->pCommaSeparated($node->params) . ')' |
466 | - . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')': '') |
|
466 | + . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')' : '') |
|
467 | 467 | . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
468 | 468 | . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; |
469 | 469 | } |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | return (null !== $node->trait ? $this->p($node->trait) . '::' : '') |
571 | 571 | . $node->method . ' as' |
572 | 572 | . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '') |
573 | - . (null !== $node->newName ? ' ' . $node->newName : '') |
|
573 | + . (null !== $node->newName ? ' ' . $node->newName : '') |
|
574 | 574 | . ';'; |
575 | 575 | } |
576 | 576 | |
@@ -761,12 +761,12 @@ discard block |
||
761 | 761 | } |
762 | 762 | |
763 | 763 | protected function pModifiers($modifiers) { |
764 | - return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') |
|
764 | + return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') |
|
765 | 765 | . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') |
766 | - . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') |
|
767 | - . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') |
|
768 | - . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') |
|
769 | - . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : ''); |
|
766 | + . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') |
|
767 | + . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') |
|
768 | + . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') |
|
769 | + . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : ''); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | protected function pEncapsList(array $encapsList, $quote) { |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | || $node instanceof Expr\ClassConstFetch |
798 | 798 | ) { |
799 | 799 | return $this->p($node); |
800 | - } else { |
|
800 | + } else { |
|
801 | 801 | return '(' . $this->p($node) . ')'; |
802 | 802 | } |
803 | 803 | } |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | || $node instanceof Expr\Array_ |
813 | 813 | ) { |
814 | 814 | return $this->p($node); |
815 | - } else { |
|
815 | + } else { |
|
816 | 816 | return '(' . $this->p($node) . ')'; |
817 | 817 | } |
818 | 818 | } |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | |
20 | 20 | public function pParam(Node\Param $node) { |
21 | 21 | return ($node->type ? $this->pType($node->type) . ' ' : '') |
22 | - . ($node->byRef ? '&' : '') |
|
23 | - . ($node->variadic ? '...' : '') |
|
24 | - . '$' . $node->name |
|
25 | - . ($node->default ? ' = ' . $this->p($node->default) : ''); |
|
22 | + . ($node->byRef ? '&' : '') |
|
23 | + . ($node->variadic ? '...' : '') |
|
24 | + . '$' . $node->name |
|
25 | + . ($node->default ? ' = ' . $this->p($node->default) : ''); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | public function pArg(Node\Arg $node) { |
@@ -357,22 +357,22 @@ discard block |
||
357 | 357 | |
358 | 358 | public function pExpr_FuncCall(Expr\FuncCall $node) { |
359 | 359 | return $this->pCallLhs($node->name) |
360 | - . '(' . $this->pCommaSeparated($node->args) . ')'; |
|
360 | + . '(' . $this->pCommaSeparated($node->args) . ')'; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | public function pExpr_MethodCall(Expr\MethodCall $node) { |
364 | 364 | return $this->pDereferenceLhs($node->var) . '->' . $this->pObjectProperty($node->name) |
365 | - . '(' . $this->pCommaSeparated($node->args) . ')'; |
|
365 | + . '(' . $this->pCommaSeparated($node->args) . ')'; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | public function pExpr_StaticCall(Expr\StaticCall $node) { |
369 | 369 | return $this->pDereferenceLhs($node->class) . '::' |
370 | - . ($node->name instanceof Expr |
|
370 | + . ($node->name instanceof Expr |
|
371 | 371 | ? ($node->name instanceof Expr\Variable |
372 | 372 | ? $this->p($node->name) |
373 | 373 | : '{' . $this->p($node->name) . '}') |
374 | 374 | : $node->name) |
375 | - . '(' . $this->pCommaSeparated($node->args) . ')'; |
|
375 | + . '(' . $this->pCommaSeparated($node->args) . ')'; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | public function pExpr_Empty(Expr\Empty_ $node) { |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | |
432 | 432 | public function pExpr_ArrayItem(Expr\ArrayItem $node) { |
433 | 433 | return (null !== $node->key ? $this->p($node->key) . ' => ' : '') |
434 | - . ($node->byRef ? '&' : '') . $this->p($node->value); |
|
434 | + . ($node->byRef ? '&' : '') . $this->p($node->value); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | public function pExpr_ArrayDimFetch(Expr\ArrayDimFetch $node) { |
438 | 438 | return $this->pDereferenceLhs($node->var) |
439 | - . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']'; |
|
439 | + . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']'; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | public function pExpr_ConstFetch(Expr\ConstFetch $node) { |
@@ -461,11 +461,11 @@ discard block |
||
461 | 461 | |
462 | 462 | public function pExpr_Closure(Expr\Closure $node) { |
463 | 463 | return ($node->static ? 'static ' : '') |
464 | - . 'function ' . ($node->byRef ? '&' : '') |
|
465 | - . '(' . $this->pCommaSeparated($node->params) . ')' |
|
466 | - . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')': '') |
|
467 | - . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
|
468 | - . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
464 | + . 'function ' . ($node->byRef ? '&' : '') |
|
465 | + . '(' . $this->pCommaSeparated($node->params) . ')' |
|
466 | + . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')': '') |
|
467 | + . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
|
468 | + . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | public function pExpr_ClosureUse(Expr\ClosureUse $node) { |
@@ -502,9 +502,9 @@ discard block |
||
502 | 502 | } else { |
503 | 503 | // this is a bit ugly, but currently there is no way to detect whether the parentheses are necessary |
504 | 504 | return '(yield ' |
505 | - . ($node->key !== null ? $this->p($node->key) . ' => ' : '') |
|
506 | - . $this->p($node->value) |
|
507 | - . ')'; |
|
505 | + . ($node->key !== null ? $this->p($node->key) . ' => ' : '') |
|
506 | + . $this->p($node->value) |
|
507 | + . ')'; |
|
508 | 508 | } |
509 | 509 | } |
510 | 510 | |
@@ -515,23 +515,23 @@ discard block |
||
515 | 515 | return 'namespace ' . $this->p($node->name) . ';' . "\n" . $this->pStmts($node->stmts, false); |
516 | 516 | } else { |
517 | 517 | return 'namespace' . (null !== $node->name ? ' ' . $this->p($node->name) : '') |
518 | - . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
518 | + . ' {' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
522 | 522 | public function pStmt_Use(Stmt\Use_ $node) { |
523 | 523 | return 'use ' . $this->pUseType($node->type) |
524 | - . $this->pCommaSeparated($node->uses) . ';'; |
|
524 | + . $this->pCommaSeparated($node->uses) . ';'; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | public function pStmt_GroupUse(Stmt\GroupUse $node) { |
528 | 528 | return 'use ' . $this->pUseType($node->type) . $this->pName($node->prefix) |
529 | - . '\{' . $this->pCommaSeparated($node->uses) . '};'; |
|
529 | + . '\{' . $this->pCommaSeparated($node->uses) . '};'; |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | public function pStmt_UseUse(Stmt\UseUse $node) { |
533 | 533 | return $this->pUseType($node->type) . $this->p($node->name) |
534 | - . ($node->name->getLast() !== $node->alias ? ' as ' . $node->alias : ''); |
|
534 | + . ($node->name->getLast() !== $node->alias ? ' as ' . $node->alias : ''); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | private function pUseType($type) { |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | |
542 | 542 | public function pStmt_Interface(Stmt\Interface_ $node) { |
543 | 543 | return 'interface ' . $node->name |
544 | - . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '') |
|
545 | - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
544 | + . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '') |
|
545 | + . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | public function pStmt_Class(Stmt\Class_ $node) { |
@@ -551,27 +551,27 @@ discard block |
||
551 | 551 | |
552 | 552 | public function pStmt_Trait(Stmt\Trait_ $node) { |
553 | 553 | return 'trait ' . $node->name |
554 | - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
554 | + . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | public function pStmt_TraitUse(Stmt\TraitUse $node) { |
558 | 558 | return 'use ' . $this->pCommaSeparated($node->traits) |
559 | - . (empty($node->adaptations) |
|
559 | + . (empty($node->adaptations) |
|
560 | 560 | ? ';' |
561 | 561 | : ' {' . $this->pStmts($node->adaptations) . "\n" . '}'); |
562 | 562 | } |
563 | 563 | |
564 | 564 | public function pStmt_TraitUseAdaptation_Precedence(Stmt\TraitUseAdaptation\Precedence $node) { |
565 | 565 | return $this->p($node->trait) . '::' . $node->method |
566 | - . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';'; |
|
566 | + . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';'; |
|
567 | 567 | } |
568 | 568 | |
569 | 569 | public function pStmt_TraitUseAdaptation_Alias(Stmt\TraitUseAdaptation\Alias $node) { |
570 | 570 | return (null !== $node->trait ? $this->p($node->trait) . '::' : '') |
571 | - . $node->method . ' as' |
|
572 | - . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '') |
|
573 | - . (null !== $node->newName ? ' ' . $node->newName : '') |
|
574 | - . ';'; |
|
571 | + . $node->method . ' as' |
|
572 | + . (null !== $node->newModifier ? ' ' . rtrim($this->pModifiers($node->newModifier), ' ') : '') |
|
573 | + . (null !== $node->newName ? ' ' . $node->newName : '') |
|
574 | + . ';'; |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | public function pStmt_Property(Stmt\Property $node) { |
@@ -580,15 +580,15 @@ discard block |
||
580 | 580 | |
581 | 581 | public function pStmt_PropertyProperty(Stmt\PropertyProperty $node) { |
582 | 582 | return '$' . $node->name |
583 | - . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); |
|
583 | + . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | public function pStmt_ClassMethod(Stmt\ClassMethod $node) { |
587 | 587 | return $this->pModifiers($node->type) |
588 | - . 'function ' . ($node->byRef ? '&' : '') . $node->name |
|
589 | - . '(' . $this->pCommaSeparated($node->params) . ')' |
|
590 | - . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
|
591 | - . (null !== $node->stmts |
|
588 | + . 'function ' . ($node->byRef ? '&' : '') . $node->name |
|
589 | + . '(' . $this->pCommaSeparated($node->params) . ')' |
|
590 | + . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
|
591 | + . (null !== $node->stmts |
|
592 | 592 | ? "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}' |
593 | 593 | : ';'); |
594 | 594 | } |
@@ -599,9 +599,9 @@ discard block |
||
599 | 599 | |
600 | 600 | public function pStmt_Function(Stmt\Function_ $node) { |
601 | 601 | return 'function ' . ($node->byRef ? '&' : '') . $node->name |
602 | - . '(' . $this->pCommaSeparated($node->params) . ')' |
|
603 | - . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
|
604 | - . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
602 | + . '(' . $this->pCommaSeparated($node->params) . ')' |
|
603 | + . (null !== $node->returnType ? ' : ' . $this->pType($node->returnType) : '') |
|
604 | + . "\n" . '{' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | public function pStmt_Const(Stmt\Const_ $node) { |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | |
611 | 611 | public function pStmt_Declare(Stmt\Declare_ $node) { |
612 | 612 | return 'declare (' . $this->pCommaSeparated($node->declares) . ')' |
613 | - . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . "\n" . '}' : ';'); |
|
613 | + . (null !== $node->stmts ? ' {' . $this->pStmts($node->stmts) . "\n" . '}' : ';'); |
|
614 | 614 | } |
615 | 615 | |
616 | 616 | public function pStmt_DeclareDeclare(Stmt\DeclareDeclare $node) { |
@@ -621,14 +621,14 @@ discard block |
||
621 | 621 | |
622 | 622 | public function pStmt_If(Stmt\If_ $node) { |
623 | 623 | return 'if (' . $this->p($node->cond) . ') {' |
624 | - . $this->pStmts($node->stmts) . "\n" . '}' |
|
625 | - . $this->pImplode($node->elseifs) |
|
626 | - . (null !== $node->else ? $this->p($node->else) : ''); |
|
624 | + . $this->pStmts($node->stmts) . "\n" . '}' |
|
625 | + . $this->pImplode($node->elseifs) |
|
626 | + . (null !== $node->else ? $this->p($node->else) : ''); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | public function pStmt_ElseIf(Stmt\ElseIf_ $node) { |
630 | 630 | return ' elseif (' . $this->p($node->cond) . ') {' |
631 | - . $this->pStmts($node->stmts) . "\n" . '}'; |
|
631 | + . $this->pStmts($node->stmts) . "\n" . '}'; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | public function pStmt_Else(Stmt\Else_ $node) { |
@@ -637,50 +637,50 @@ discard block |
||
637 | 637 | |
638 | 638 | public function pStmt_For(Stmt\For_ $node) { |
639 | 639 | return 'for (' |
640 | - . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '') |
|
641 | - . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '') |
|
642 | - . $this->pCommaSeparated($node->loop) |
|
643 | - . ') {' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
640 | + . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '') |
|
641 | + . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '') |
|
642 | + . $this->pCommaSeparated($node->loop) |
|
643 | + . ') {' . $this->pStmts($node->stmts) . "\n" . '}'; |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | public function pStmt_Foreach(Stmt\Foreach_ $node) { |
647 | 647 | return 'foreach (' . $this->p($node->expr) . ' as ' |
648 | - . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '') |
|
649 | - . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {' |
|
650 | - . $this->pStmts($node->stmts) . "\n" . '}'; |
|
648 | + . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '') |
|
649 | + . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {' |
|
650 | + . $this->pStmts($node->stmts) . "\n" . '}'; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | public function pStmt_While(Stmt\While_ $node) { |
654 | 654 | return 'while (' . $this->p($node->cond) . ') {' |
655 | - . $this->pStmts($node->stmts) . "\n" . '}'; |
|
655 | + . $this->pStmts($node->stmts) . "\n" . '}'; |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | public function pStmt_Do(Stmt\Do_ $node) { |
659 | 659 | return 'do {' . $this->pStmts($node->stmts) . "\n" |
660 | - . '} while (' . $this->p($node->cond) . ');'; |
|
660 | + . '} while (' . $this->p($node->cond) . ');'; |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | public function pStmt_Switch(Stmt\Switch_ $node) { |
664 | 664 | return 'switch (' . $this->p($node->cond) . ') {' |
665 | - . $this->pStmts($node->cases) . "\n" . '}'; |
|
665 | + . $this->pStmts($node->cases) . "\n" . '}'; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | public function pStmt_Case(Stmt\Case_ $node) { |
669 | 669 | return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':' |
670 | - . $this->pStmts($node->stmts); |
|
670 | + . $this->pStmts($node->stmts); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | public function pStmt_TryCatch(Stmt\TryCatch $node) { |
674 | 674 | return 'try {' . $this->pStmts($node->stmts) . "\n" . '}' |
675 | - . $this->pImplode($node->catches) |
|
676 | - . ($node->finallyStmts !== null |
|
675 | + . $this->pImplode($node->catches) |
|
676 | + . ($node->finallyStmts !== null |
|
677 | 677 | ? ' finally {' . $this->pStmts($node->finallyStmts) . "\n" . '}' |
678 | 678 | : ''); |
679 | 679 | } |
680 | 680 | |
681 | 681 | public function pStmt_Catch(Stmt\Catch_ $node) { |
682 | 682 | return ' catch (' . $this->p($node->type) . ' $' . $node->var . ') {' |
683 | - . $this->pStmts($node->stmts) . "\n" . '}'; |
|
683 | + . $this->pStmts($node->stmts) . "\n" . '}'; |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | public function pStmt_Break(Stmt\Break_ $node) { |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | |
724 | 724 | public function pStmt_StaticVar(Stmt\StaticVar $node) { |
725 | 725 | return '$' . $node->name |
726 | - . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); |
|
726 | + . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | public function pStmt_Unset(Stmt\Unset_ $node) { |
@@ -762,11 +762,11 @@ discard block |
||
762 | 762 | |
763 | 763 | protected function pModifiers($modifiers) { |
764 | 764 | return ($modifiers & Stmt\Class_::MODIFIER_PUBLIC ? 'public ' : '') |
765 | - . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') |
|
766 | - . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') |
|
767 | - . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') |
|
768 | - . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') |
|
769 | - . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : ''); |
|
765 | + . ($modifiers & Stmt\Class_::MODIFIER_PROTECTED ? 'protected ' : '') |
|
766 | + . ($modifiers & Stmt\Class_::MODIFIER_PRIVATE ? 'private ' : '') |
|
767 | + . ($modifiers & Stmt\Class_::MODIFIER_STATIC ? 'static ' : '') |
|
768 | + . ($modifiers & Stmt\Class_::MODIFIER_ABSTRACT ? 'abstract ' : '') |
|
769 | + . ($modifiers & Stmt\Class_::MODIFIER_FINAL ? 'final ' : ''); |
|
770 | 770 | } |
771 | 771 | |
772 | 772 | protected function pEncapsList(array $encapsList, $quote) { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $this->code = $code; // keep the code around for __halt_compiler() handling |
64 | 64 | $this->pos = -1; |
65 | - $this->line = 1; |
|
65 | + $this->line = 1; |
|
66 | 66 | $this->filePos = 0; |
67 | 67 | } |
68 | 68 | |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | if (T_DOUBLE_COLON === $i) { |
265 | 265 | // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM |
266 | 266 | $tokenMap[$i] = Tokens::T_PAAMAYIM_NEKUDOTAYIM; |
267 | - } elseif(T_OPEN_TAG_WITH_ECHO === $i) { |
|
267 | + } elseif (T_OPEN_TAG_WITH_ECHO === $i) { |
|
268 | 268 | // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO |
269 | 269 | $tokenMap[$i] = Tokens::T_ECHO; |
270 | - } elseif(T_CLOSE_TAG === $i) { |
|
270 | + } elseif (T_CLOSE_TAG === $i) { |
|
271 | 271 | // T_CLOSE_TAG is equivalent to ';' |
272 | 272 | $tokenMap[$i] = ord(';'); |
273 | 273 | } elseif ('UNKNOWN' !== $name = token_name($i)) { |
@@ -117,7 +117,7 @@ |
||
117 | 117 | } |
118 | 118 | if ($num <= 0x1FFFFF) { |
119 | 119 | return chr(($num>>18) + 0xF0) . chr((($num>>12)&0x3F) + 0x80) |
120 | - . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
120 | + . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
121 | 121 | } |
122 | 122 | throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); |
123 | 123 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if ('\'' === $str[$bLength]) { |
56 | 56 | return str_replace( |
57 | 57 | array('\\\\', '\\\''), |
58 | - array( '\\', '\''), |
|
58 | + array('\\', '\''), |
|
59 | 59 | substr($str, $bLength + 1, -1) |
60 | 60 | ); |
61 | 61 | } else { |
@@ -110,14 +110,14 @@ discard block |
||
110 | 110 | return chr($num); |
111 | 111 | } |
112 | 112 | if ($num <= 0x7FF) { |
113 | - return chr(($num>>6) + 0xC0) . chr(($num&0x3F) + 0x80); |
|
113 | + return chr(($num >> 6) + 0xC0) . chr(($num & 0x3F) + 0x80); |
|
114 | 114 | } |
115 | 115 | if ($num <= 0xFFFF) { |
116 | - return chr(($num>>12) + 0xE0) . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
116 | + return chr(($num >> 12) + 0xE0) . chr((($num >> 6) & 0x3F) + 0x80) . chr(($num & 0x3F) + 0x80); |
|
117 | 117 | } |
118 | 118 | if ($num <= 0x1FFFFF) { |
119 | - return chr(($num>>18) + 0xF0) . chr((($num>>12)&0x3F) + 0x80) |
|
120 | - . chr((($num>>6)&0x3F) + 0x80) . chr(($num&0x3F) + 0x80); |
|
119 | + return chr(($num >> 18) + 0xF0) . chr((($num >> 12) & 0x3F) + 0x80) |
|
120 | + . chr((($num >> 6) & 0x3F) + 0x80) . chr(($num & 0x3F) + 0x80); |
|
121 | 121 | } |
122 | 122 | throw new Error('Invalid UTF-8 codepoint escape sequence: Codepoint too large'); |
123 | 123 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | public function __construct($name, array $subNodes = array(), array $attributes = array()) { |
37 | 37 | parent::__construct($attributes); |
38 | 38 | $this->type = isset($subNodes['type']) ? $subNodes['type'] : 0; |
39 | - $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; |
|
39 | + $this->byRef = isset($subNodes['byRef']) ? $subNodes['byRef'] : false; |
|
40 | 40 | $this->name = $name; |
41 | 41 | $this->params = isset($subNodes['params']) ? $subNodes['params'] : array(); |
42 | 42 | $this->returnType = isset($subNodes['returnType']) ? $subNodes['returnType'] : null; |
@@ -7,10 +7,10 @@ |
||
7 | 7 | |
8 | 8 | class Class_ extends ClassLike |
9 | 9 | { |
10 | - const MODIFIER_PUBLIC = 1; |
|
11 | - const MODIFIER_PROTECTED = 2; |
|
12 | - const MODIFIER_PRIVATE = 4; |
|
13 | - const MODIFIER_STATIC = 8; |
|
10 | + const MODIFIER_PUBLIC = 1; |
|
11 | + const MODIFIER_PROTECTED = 2; |
|
12 | + const MODIFIER_PRIVATE = 4; |
|
13 | + const MODIFIER_STATIC = 8; |
|
14 | 14 | const MODIFIER_ABSTRACT = 16; |
15 | 15 | const MODIFIER_FINAL = 32; |
16 | 16 |