From 4d2a4d02b08b75d00067f8bf8b3c58a993abc0d0 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 23 Dec 2016 14:11:31 +0100 Subject: [PATCH] Add first shot at format preserving pretty printer --- formatPreserving.php | 56 ++ grammar/php5.y | 25 +- grammar/php7.y | 8 +- grammar/rebuildParsers.php | 2 +- lib/PhpParser/Node/Stmt/Do_.php | 6 +- lib/PhpParser/NodeAbstract.php | 4 + lib/PhpParser/NodeVisitor/CloningVisitor.php | 19 + lib/PhpParser/Parser/Php5.php | 780 +++++++++--------- lib/PhpParser/Parser/Php7.php | 614 +++++++------- lib/PhpParser/ParserAbstract.php | 96 ++- lib/PhpParser/PrettyPrinter/Standard.php | 47 +- lib/PhpParser/PrettyPrinterAbstract.php | 613 +++++++++++++- test/PhpParser/CodeTestAbstract.php | 9 +- test/PhpParser/PrettyPrinterTest.php | 117 ++- test/code/formatPreservation/abc1.test | 267 ++++++ test/code/parser/stmt/blocklessStatement.test | 6 +- test/code/parser/stmt/generator/basic.test | 4 +- test/code/parser/stmt/loop/do.test | 4 +- 18 files changed, 1895 insertions(+), 782 deletions(-) create mode 100644 formatPreserving.php create mode 100644 lib/PhpParser/NodeVisitor/CloningVisitor.php create mode 100644 test/code/formatPreservation/abc1.test diff --git a/formatPreserving.php b/formatPreserving.php new file mode 100644 index 0000000000..5a3c29026e --- /dev/null +++ b/formatPreserving.php @@ -0,0 +1,56 @@ + [ + 'comments', + 'startLine', 'endLine', + 'startFilePos', 'endFilePos', + 'startTokenPos', 'endTokenPos', + ], +]); + +$parser = new PhpParser\Parser\Php7($lexer, [ + 'useIdentifierNodes' => true, + 'useConsistentVariableNodes' => true, + ] +); + +$traverser = new PhpParser\NodeTraverser(); +$traverser->addVisitor(new PhpParser\NodeVisitor\CloningVisitor()); + +$printer = new PhpParser\PrettyPrinter\Standard(); + +$code = <<<'PHP' +parse($code); +$oldTokens = $lexer->getTokens(); + +$newStmts = $traverser->traverse($oldStmts); + +$newStmts[0]->stmts[0]->exprs[0]->left->right->value = 42; +$newStmts[0]->stmts[1] = new Node\Expr\Assign(new Node\Expr\Variable('a'), new Node\Scalar\LNumber(42)); + +$newCode = $printer->printFormatPreserving($newStmts, $oldStmts, $code, $oldTokens); +echo $newCode, "\n"; \ No newline at end of file diff --git a/grammar/php5.y b/grammar/php5.y index a0e7fde29a..ce1b3ff4b6 100644 --- a/grammar/php5.y +++ b/grammar/php5.y @@ -690,21 +690,8 @@ function_call: { $$ = Expr\StaticCall[$1, $3, $4]; } | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' argument_list { $$ = Expr\StaticCall[$1, $4, $6]; } - | static_property argument_list { - if ($1 instanceof Node\Expr\StaticPropertyFetch) { - $$ = Expr\StaticCall[$1->class, Expr\Variable[$1->name], $2]; - } elseif ($1 instanceof Node\Expr\ArrayDimFetch) { - $tmp = $1; - while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { - $tmp = $tmp->var; - } - - $$ = Expr\StaticCall[$tmp->var->class, $1, $2]; - $tmp->var = Expr\Variable[$tmp->var->name]; - } else { - throw new \Exception; - } - } + | static_property argument_list + { $$ = $this->fixupPhp5StaticPropCall($1, $2, attributes()); } | variable_without_objects argument_list { $$ = Expr\FuncCall[$1, $2]; } | function_call '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } @@ -992,14 +979,18 @@ encaps_base_var: T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } ; +encaps_str_varname: + T_STRING_VARNAME { $$ = Expr\Variable[$1]; } +; + encaps_var: encaps_base_var { $$ = $1; } | encaps_base_var '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | encaps_base_var T_OBJECT_OPERATOR identifier { $$ = Expr\PropertyFetch[$1, $3]; } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr\Variable[$2]; } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr\Variable[$2]; } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' - { $$ = Expr\ArrayDimFetch[Expr\Variable[$2], $4]; } + | T_DOLLAR_OPEN_CURLY_BRACES encaps_str_varname '[' expr ']' '}' + { $$ = Expr\ArrayDimFetch[$2, $4]; } | T_CURLY_OPEN variable '}' { $$ = $2; } ; diff --git a/grammar/php7.y b/grammar/php7.y index 44f1313593..83e569d85a 100644 --- a/grammar/php7.y +++ b/grammar/php7.y @@ -881,14 +881,18 @@ encaps_base_var: T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } ; +encaps_str_varname: + T_STRING_VARNAME { $$ = Expr\Variable[$1]; } +; + encaps_var: encaps_base_var { $$ = $1; } | encaps_base_var '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | encaps_base_var T_OBJECT_OPERATOR identifier { $$ = Expr\PropertyFetch[$1, $3]; } | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr\Variable[$2]; } | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr\Variable[$2]; } - | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' - { $$ = Expr\ArrayDimFetch[Expr\Variable[$2], $4]; } + | T_DOLLAR_OPEN_CURLY_BRACES encaps_str_varname '[' expr ']' '}' + { $$ = Expr\ArrayDimFetch[$2, $4]; } | T_CURLY_OPEN variable '}' { $$ = $2; } ; diff --git a/grammar/rebuildParsers.php b/grammar/rebuildParsers.php index 45b26b9d73..b353d39b28 100644 --- a/grammar/rebuildParsers.php +++ b/grammar/rebuildParsers.php @@ -179,7 +179,7 @@ function($matches) { assertArgs(2, $args, $name); return '$startAttributes = ' . $args[1] . ';' - . ' if (isset($startAttributes[\'comments\']))' + . ' if ($this->useNopStatements && isset($startAttributes[\'comments\']))' . ' { ' . $args[0] . ' = new Stmt\Nop([\'comments\' => $startAttributes[\'comments\']]); }' . ' else { ' . $args[0] . ' = null; }'; } diff --git a/lib/PhpParser/Node/Stmt/Do_.php b/lib/PhpParser/Node/Stmt/Do_.php index dd4c6c8436..77b0ff41c2 100644 --- a/lib/PhpParser/Node/Stmt/Do_.php +++ b/lib/PhpParser/Node/Stmt/Do_.php @@ -6,10 +6,10 @@ class Do_ extends Node\Stmt { - /** @var Node\Expr Condition */ - public $cond; /** @var Node[] Statements */ public $stmts; + /** @var Node\Expr Condition */ + public $cond; /** * Constructs a do while node. @@ -25,6 +25,6 @@ public function __construct(Node\Expr $cond, array $stmts = array(), array $attr } public function getSubNodeNames() { - return array('cond', 'stmts'); + return array('stmts', 'cond'); } } diff --git a/lib/PhpParser/NodeAbstract.php b/lib/PhpParser/NodeAbstract.php index 62a96da118..f2f6797cc3 100644 --- a/lib/PhpParser/NodeAbstract.php +++ b/lib/PhpParser/NodeAbstract.php @@ -105,6 +105,10 @@ public function getAttributes() { return $this->attributes; } + public function setAttributes(array $attributes) { + $this->attributes = $attributes; + } + public function jsonSerialize() { return ['nodeType' => $this->getType()] + get_object_vars($this); } diff --git a/lib/PhpParser/NodeVisitor/CloningVisitor.php b/lib/PhpParser/NodeVisitor/CloningVisitor.php new file mode 100644 index 0000000000..d91a00cd7e --- /dev/null +++ b/lib/PhpParser/NodeVisitor/CloningVisitor.php @@ -0,0 +1,19 @@ +setAttribute('origNode', $origNode); + return $node; + } +} \ No newline at end of file diff --git a/lib/PhpParser/Parser/Php5.php b/lib/PhpParser/Parser/Php5.php index 2e47f0c383..e85e968481 100644 --- a/lib/PhpParser/Parser/Php5.php +++ b/lib/PhpParser/Parser/Php5.php @@ -18,16 +18,16 @@ class Php5 extends \PhpParser\ParserAbstract { protected $tokenToSymbolMapSize = 392; - protected $actionTableSize = 1004; - protected $gotoTableSize = 638; + protected $actionTableSize = 1003; + protected $gotoTableSize = 637; protected $invalidSymbol = 157; protected $errorSymbol = 1; protected $defaultAction = -32766; protected $unexpectedTokenRule = 32767; - protected $YY2TBLSTATE = 405; - protected $YYNLSTATES = 668; + protected $YY2TBLSTATE = 404; + protected $YYNLSTATES = 669; protected $symbolToName = array( "EOF", @@ -233,107 +233,107 @@ class Php5 extends \PhpParser\ParserAbstract ); protected $action = array( - 673, 674, 675, 676, 677,-32766, 678, 679, 680, 716, - 717, 216, 217, 218, 219, 220, 221, 222, 223, 224, - 23, 225, 226, 227, 228, 229, 230, 231, 232, 233, + 674, 675, 676, 677, 678,-32766, 679, 680, 681, 717, + 718, 216, 217, 218, 219, 220, 221, 222, 223, 224, + 282, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236,-32766,-32766,-32766,-32766,-32766,-32766,-32766, - -32766,-32767,-32767,-32767,-32767, 8, 237, 238,-32766,-32766, - -32766,-32766, 681,-32766, 0,-32766,-32766,-32766,-32766,-32766, - -32766,-32767,-32767,-32767,-32767,-32767, 682, 683, 684, 685, - 686, 687, 688, 1176, 204, 748,-32766,-32766,-32766,-32766, - -32766, 423, 689, 690, 691, 692, 693, 694, 695, 696, - 697, 698, 699, 719, 720, 721, 722, 723, 711, 712, - 713, 714, 715, 700, 701, 702, 703, 704, 705, 706, - 742, 743, 744, 745, 746, 747, 707, 708, 709, 710, - 740, 731, 729, 730, 726, 727, 121, 718, 724, 725, - 732, 733, 735, 734, 736, 737, 52, 53, 424, 54, - 55, 728, 739, 738, 282, 56, 57, 339, 58,-32766, + -32766,-32767,-32767,-32767,-32767, 419, 237, 238,-32766,-32766, + -32766,-32766, 682,-32766, 0,-32766,-32766,-32766,-32766,-32766, + -32766,-32767,-32767,-32767,-32767,-32767, 683, 684, 685, 686, + 687, 688, 689, 1184, 348, 749,-32766,-32766,-32766,-32766, + -32766, 23, 690, 691, 692, 693, 694, 695, 696, 697, + 698, 699, 700, 720, 721, 722, 723, 724, 712, 713, + 714, 715, 716, 701, 702, 703, 704, 705, 706, 707, + 743, 744, 745, 746, 747, 748, 708, 709, 710, 711, + 741, 732, 730, 731, 727, 728, 28, 719, 725, 726, + 733, 734, 736, 735, 737, 738, 52, 53, 423, 54, + 55, 729, 740, 739, 420, 56, 57, 332, 58,-32766, -32766,-32766,-32766,-32766,-32766,-32766,-32766,-32766, 7,-32767, - -32767,-32767,-32767, 50, 329, 903, 589, 948, 949, 950, - 947, 946, 945, 940, 1218, 306, 1220, 1219, 766, 767, - 824, 59, 60,-32766,-32766,-32766, 922, 61, 1176, 62, + -32767,-32767,-32767, 50, 329, 1192, 523, 949, 950, 951, + 948, 947, 946, 941, 1220, 121, 1222, 1221, 767, 768, + 825, 59, 60,-32766,-32766,-32766, 812, 61, 1177, 62, 291, 292, 63, 64, 65, 66, 67, 68, 69, 70, - 420, 24, 299, 71, 416,-32766,-32766,-32766, 1190, 1091, - 1092, 751, 750, 1183, 213, 214, 215, 473,-32766,-32766, - -32766, 825, 409, 1103, 309,-32766, 1058,-32766,-32766,-32766, - -32766,-32766,-32766, 1040, 200, -271, 436, 1040,-32766, 421, - -32766,-32766,-32766,-32766,-32766, 120, 497, 948, 949, 950, - 947, 946, 945, 348, 481, 482, 293, 624, 125,-32766, - 896, 897, 339, 483, 484,-32766, 1097, 1098, 1099, 1100, - 1094, 1095, 307, 498,-32766, 358, 432, 498, 1101, 1096, - 432, 326, -222, 872, 750, 39, 280, 332, 321, 1191, - 322, 425, -124, -124, -124, -4, 825, 472, 99, 100, - 101, 813, 301, 377, 38, 19, 426, -124, 474, -124, - 475, -124, 476, -124, 102, 427, -124, -124, -124, 28, - 29, 428, 429, 625, 30, 477, 432, 815, 72, 297, - 926, 350, 349, 478, 479,-32766,-32766,-32766, 298, 480, - 1040, 811, 796, 843, 430, 431,-32767,-32767,-32767,-32767, + 358, 24, 299, 71, 415,-32766,-32766,-32766, 1191, 1092, + 1093, 752, 751, 1184, 213, 214, 215, 472,-32766,-32766, + -32766, 826, 408, 1104, 309,-32766, 904,-32766,-32766,-32766, + -32766,-32766,-32766, 1041, 200, -271, 435, 1041,-32766, 422, + -32766,-32766,-32766,-32766,-32766, 120, 496, 949, 950, 951, + 948, 947, 946, 204, 480, 481, 296, 625, 125,-32766, + 897, 898, 339, 482, 483,-32766, 1098, 1099, 1100, 1101, + 1095, 1096, 307, 497,-32766, 421, 431, 497, 1102, 1097, + 431, 306, -222, 873, 751, 39, 280, 332, 321, 18, + 322, 424, -124, -124, -124, -4, 826, 471, 99, 100, + 101, 814, 301, 549, 38, 19, 425, -124, 473, -124, + 474, -124, 475, -124, 102, 426, -124, -124, -124, 29, + 30, 427, 428, 626, 31, 476, 431, 816, 72, 326, + 927, 350, 349, 477, 478,-32766,-32766,-32766, 298, 479, + 1041, 811, 797, 844, 429, 430,-32767,-32767,-32767,-32767, 94, 95, 96, 97, 98,-32766, 126,-32766,-32766,-32766, - -32766, 1141, 213, 214, 215, 295, 425, 239, 827, 639, - -124, 1040, 472, 896, 897, 1210, 813, 1040, 1209, 38, - 19, 426, 200, 474, 18, 475, 498, 476, 127, 432, - 427, 213, 214, 215, 28, 29, 428, 429, 407, 30, - 477, 1040, 873, 72, 320, 825, 350, 349, 478, 479, - 1040, 200, 214, 215, 480, 419, 810, 758, 843, 430, - 431, 213, 214, 215, 295, -218, 76, 77, 78, 47, - 338, 200, 483, 648, 27, 446, 31, 294, 331, 422, - 335, 200, 241, 827, 639, -4, 32, 415, 79, 80, + -32766, 1142, 213, 214, 215, 295, 424, 239, 828, 640, + -124, 1041, 471, 897, 898, 1211, 814, 1041, 1210, 38, + 19, 425, 200, 473, 1059, 474, 497, 475, 414, 431, + 426, 213, 214, 215, 29, 30, 427, 428, 406, 31, + 476, 1041, 874, 72, 320, 826, 350, 349, 477, 478, + 338, 200, 214, 215, 479, 8, 922, 759, 844, 429, + 430, 213, 214, 215, 295, -218, 76, 77, 78, 46, + 590, 200, 482, 644, 297, 445, 27, 294, 331, 418, + 335, 200, 241, 828, 640, -4, 32, 1041, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 1215, 301, 34, 825, 425, 804, 124,-32766,-32766, - -32766, 472, 902, 129, 102, 813, 912, 580, 38, 19, - 426, 449, 474, 1183, 475, 119, 476, 46,-32766, 427, - -32766,-32766, 643, 28, 29, 428, 825, 806, 30, 477, - 417, 117, 72, 808, 49, 350, 349,-32766,-32766,-32766, - -32766,-32766,-32766, 480, 200, 1040, 234, 235, 236,-32766, - -32766,-32766,-32766,-32766, 654, 1142, 124,-32766,-32766,-32766, - -32766,-32766, 237, 238, 425, 96, 97, 98, 283,-32766, - 472, 524, 827, 639, 813, 447, 765, 38, 19, 426, - 284, 474, 647, 475, 751, 476, 1183, 332, 427, 231, - 232, 233, 28, 29, 428, 825, 425, 30, 477, 116, - 921, 72, 472, 215, 350, 349, 813, 242, 1040, 38, - 19, 426, 480, 474, 243, 475, 118, 476, 1040, 1068, - 427, 200, 836, 642, 28, 29, 428, 825, 1103, 30, - 477, 296, 115, 72, 207, 123, 350, 349,-32766,-32766, - 498, 827, 639, 432, 480, 206, 213, 214, 215, 442, - 498, 244, 641, 432, 205, 645, 237, 238, 437,-32766, - 332, 456, 20, 461, 595, 425, 200, 130, 359, 766, - 767, 472, 313, 827, 639, 813, 925, 667, 38, 19, - 426, 651, 474, 823, 475, 128, 476, 602, 603, 427, - -82, 759, 644, 28, 29, 428, 825, 425, 30, 477, - 937, 657, 72, 472, 301, 350, 349, 813, 102, 299, - 38, 19, 426, 480, 474, 45, 475, 752, 476, 608, - 41, 427, 48, 751, 42, 28, 29, 428, 750, 44, - 30, 477, 51, 43, 72, 445, 633, 350, 349, 754, - -32766, 530, 827, 639, 600, 480, 953, 33, 103, 104, + 101, 448, 301, 215, 826, 424, 805, 124,-32766,-32766, + -32766, 471, 903, 244, 102, 814, 1177, 1104, 38, 19, + 425, 200, 473, 913, 474, 119, 475, 47,-32766, 426, + -32766,-32766, 643, 29, 30, 427, 826, 807, 31, 476, + 416, 116, 72, 809, 49, 350, 349,-32766,-32766,-32766, + -32766,-32766,-32766, 479, 34, 1041, 234, 235, 236, 213, + 214, 215,-32766,-32766, 649, 1143, 124,-32766,-32766,-32766, + -32766,-32766, 237, 238, 424, 231, 232, 233, 293, 200, + 471, 243, 828, 640, 814, 446, 923, 38, 19, 425, + 339, 473, 242, 474, 752, 475, 1184, 284, 426, 96, + 97, 98, 29, 30, 427, 826, 424, 31, 476, 117, + 766, 72, 471, 129, 350, 349, 814, 581, 1041, 38, + 19, 425, 479, 473, 115, 474, 118, 475, 1041, 1069, + 426,-32766,-32766, 655, 29, 30, 427, 826, 206, 31, + 476, 283, 205, 72, 207, 123, 350, 349, 237, 238, + 497, 828, 640, 431, 479, 648,-32766,-32766,-32766, 441, + 497, 200, 642, 431, 824, 646, 460, 596, 436, 128, + 332, 455, 20, 130, 359, 424,-32766, 767, 768, 603, + 604, 471, 313, 828, 640, 814, 926, 668, 38, 19, + 425, -82, 473, 652, 474, 837, 475, 760, 645, 426, + -32766, 938, 658, 29, 30, 427, 826, 424, 31, 476, + 301, 102, 72, 471, 44, 350, 349, 814, 45, 48, + 38, 19, 425, 479, 473, 127, 474, 299, 475, 609, + 43, 426, 41, 42, 51, 29, 30, 427, 753, 529, + 31, 476, 613, 634, 72, 752, 587, 350, 349, 751, + 755, 601, 828, 640, 954, 479,-32766, 33, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, - 583, 620, 612, 334, 586, -80, 425, 845, 448, 12, - 279, 1102, 472, 599, 859, 639, 813, 410, 406, 38, - 19, 426, 440, 474, 466, 475, 240, 476, 979, 981, - 427, 330, -501, 0, 28, 29, 428, 0, 327, 30, - 477, 844, 1148, 72, 208, 209, 350, 349, 483, 0, - 210, 328, 211, -500, 480, 308, 310, 0, 0, 0, - 0, 0, 0, 0, 202, 9, 0, 0, 4, 208, - 209, 357, 1091, 1092, -409, 210,-32766, 211, -401, 3, - 1093, 11, -410, 827, 639, 838, -219, 411, 532, 202, - 442, 393, 385, 384, 372, 1044, 0, 1091, 1092, 812, - -500,-32766, 662, 661, 37, 1093, 36, 763, 762, 929, - 805, 931, 807, 809, 821, 764, 814, 930, 932, 933, - 0, 855, 857, 860, 799, 867, 866, 569, 875, 1097, - 1098, 1099, 1100, 1094, 1095, 383, 816, 801, 822, 1020, - 325, 1101, 1096, 324, 122, 75, 1038, 405, 212, 666, - -32766, 665, 569, 664, 1097, 1098, 1099, 1100, 1094, 1095, - 383, 659, 656, 655, 653, 652, 1101, 1096, 650, 640, - 1019, 938, 606, 212, 830,-32766, 865, 839, 864, 768, - 769, 460, 1214, 1184, 1182, 1167, 1180, 1082, 914, 1188, - 1178, 1054, 840, 841, 1043, 1042, 832, 1216, 760, 761, - 1217, 797, 663, 771, 770, 842, 0, 305, 304, 303, - 336, 302, 290, 22, 25, 289, 408, 414, 281, 203, - 26, 35, 40, 74, 73,-32766, 0, 573, 1084, 1107, - 904, 1048, 1045, 630, 563, 470, 465, 464, 457, 378, - 16, 15, 14, -218, 0, 0, -419, 0, 1162, 1161, - 1108, 1212, 1081, 1179, 1049, 1166, 1181, 1067, 1052, 1053, - 1050, 1051, 0, 1147 + 444, 621, 584, 12, 600, 279, 424, -80, 465, 439, + 447, 9, 471, 330, 860, 640, 814, 409, 4, 38, + 19, 425, 815, 473, 305, 474, 240, 475, 980, 982, + 426, 0, 0, 0, 29, 30, 427, 0, 334, 31, + 476, 846, 845, 72, 208, 209, 350, 349, 327, 308, + 210, 328, 211, -501, 479, -500, 310, 0, 482, 1103, + 0, 0, 1149, 410, 202, 0, 0, 0, 357, 208, + 209, 0, 1092, 1093, -409, 210,-32766, 211, -401, -410, + 1094, 3, 11, 828, 640, 839, -219, 531, 441, 202, + 392, 384, 383, 372, 304, 0, 663, 1092, 1093, 662, + -500,-32766, 37, 36, 764, 1094, 763, 930, 806, 932, + 808, 810, 822, 813, 765, 931, 933, 934, 856, 858, + 0, 861, 800, 868, 867, 876, 817, 570, 802, 1098, + 1099, 1100, 1101, 1095, 1096, 382, 823, 939, 405, 325, + 324, 1102, 1097, 122, 75, 404, 1039, 667, 212, 666, + -32766, 665, 570, 660, 1098, 1099, 1100, 1101, 1095, 1096, + 382, 657, 656, 654, 653, 651, 1102, 1097, 641, 303, + 831, 866, 607, 212, 840,-32766, 1043, 865, 769, 770, + 459, 1216, 1185, 1183, 1168, 1181, 1083, 915, 1189, 1179, + 1055, 841, 842, 1044, 833, 1218, 761, 762, 1219, 1217, + 798, 664, 772, 771, 843, 0, 336, 302, 290, 22, + 25, 289, 407, 413, 281, 203, 26, 35, 40, 74, + 73,-32766, 0, 1045, 1021, 1020, 574, 1085, 1108, 905, + 1049, 1046, 631, 564, 469, 464, 463, 456, 377, 16, + 15, 14, -218, 0, 0, -419, 0, 1163, 1162, 1109, + 1214, 1082, 1180, 1050, 1167, 1182, 1068, 1053, 1054, 1051, + 1052, 0, 1148 ); protected $actionCheck = array( @@ -375,143 +375,144 @@ class Php5 extends \PhpParser\ParserAbstract 45, 46, 47, 48, 49, 28, 149, 30, 31, 32, 33, 155, 8, 9, 10, 35, 71, 13, 148, 149, 150, 12, 77, 130, 131, 79, 81, 12, 82, 84, - 85, 86, 28, 88, 152, 90, 143, 92, 67, 146, + 85, 86, 28, 88, 152, 90, 143, 92, 7, 146, 95, 8, 9, 10, 99, 100, 101, 102, 103, 104, 105, 12, 148, 108, 109, 1, 111, 112, 113, 114, - 12, 28, 9, 10, 119, 7, 148, 122, 123, 124, + 67, 28, 9, 10, 119, 7, 148, 122, 123, 124, 125, 8, 9, 10, 35, 152, 8, 9, 10, 67, - 67, 28, 129, 29, 7, 29, 140, 141, 143, 7, - 7, 28, 29, 148, 149, 150, 28, 7, 30, 31, + 82, 28, 129, 29, 7, 29, 140, 141, 143, 7, + 7, 28, 29, 148, 149, 150, 28, 12, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 150, 54, 13, 1, 71, 148, 147, 8, 9, - 10, 77, 152, 149, 66, 81, 79, 153, 84, 85, - 86, 128, 88, 79, 90, 13, 92, 67, 28, 95, + 52, 128, 54, 10, 1, 71, 148, 147, 8, 9, + 10, 77, 152, 15, 66, 81, 79, 139, 84, 85, + 86, 28, 88, 79, 90, 13, 92, 67, 28, 95, 30, 31, 29, 99, 100, 101, 1, 148, 104, 105, 123, 149, 108, 148, 67, 111, 112, 8, 9, 10, - 31, 32, 33, 119, 28, 12, 50, 51, 52, 8, + 31, 32, 33, 119, 13, 12, 50, 51, 52, 8, 9, 10, 8, 9, 29, 152, 147, 28, 151, 30, 31, 32, 66, 67, 71, 47, 48, 49, 35, 28, - 77, 82, 148, 149, 81, 149, 148, 84, 85, 86, - 153, 88, 29, 90, 77, 92, 79, 153, 95, 47, + 77, 15, 148, 149, 81, 149, 148, 84, 85, 86, + 153, 88, 15, 90, 77, 92, 79, 153, 95, 47, 48, 49, 99, 100, 101, 1, 71, 104, 105, 149, - 148, 108, 77, 10, 111, 112, 81, 15, 12, 84, + 148, 108, 77, 149, 111, 112, 81, 153, 12, 84, 85, 86, 119, 88, 15, 90, 149, 92, 12, 112, - 95, 28, 35, 29, 99, 100, 101, 1, 139, 104, - 105, 35, 15, 108, 15, 29, 111, 112, 31, 32, - 143, 148, 149, 146, 119, 15, 8, 9, 10, 146, - 143, 15, 149, 146, 15, 29, 66, 67, 151, 31, - 153, 72, 73, 72, 73, 71, 28, 97, 98, 102, - 103, 77, 29, 148, 149, 81, 148, 149, 84, 85, - 86, 29, 88, 29, 90, 29, 92, 106, 107, 95, - 29, 148, 149, 99, 100, 101, 1, 71, 104, 105, - 148, 149, 108, 77, 54, 111, 112, 81, 66, 68, - 84, 85, 86, 119, 88, 67, 90, 77, 92, 74, - 67, 95, 67, 77, 67, 99, 100, 101, 77, 67, - 104, 105, 67, 67, 108, 86, 89, 111, 112, 79, - 82, 82, 148, 149, 109, 119, 79, 15, 16, 17, + 95, 31, 32, 29, 99, 100, 101, 1, 15, 104, + 105, 35, 15, 108, 15, 29, 111, 112, 66, 67, + 143, 148, 149, 146, 119, 29, 8, 9, 10, 146, + 143, 28, 149, 146, 29, 29, 72, 73, 151, 29, + 153, 72, 73, 97, 98, 71, 28, 102, 103, 106, + 107, 77, 29, 148, 149, 81, 148, 149, 84, 85, + 86, 29, 88, 29, 90, 35, 92, 148, 149, 95, + 31, 148, 149, 99, 100, 101, 1, 71, 104, 105, + 54, 66, 108, 77, 67, 111, 112, 81, 67, 67, + 84, 85, 86, 119, 88, 67, 90, 68, 92, 74, + 67, 95, 67, 67, 67, 99, 100, 101, 77, 82, + 104, 105, 93, 89, 108, 77, 96, 111, 112, 77, + 79, 109, 148, 149, 79, 119, 82, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, - 87, 91, 93, 126, 96, 94, 71, 123, 94, 94, - 94, 139, 77, 96, 148, 149, 81, 146, 149, 84, - 85, 86, 102, 88, 102, 90, 29, 92, 56, 57, - 95, 110, 128, -1, 99, 100, 101, -1, 126, 104, - 105, 123, 139, 108, 47, 48, 111, 112, 129, -1, - 53, 127, 55, 128, 119, 128, 128, -1, -1, -1, - -1, -1, -1, -1, 67, 142, -1, -1, 142, 47, - 48, 142, 75, 76, 142, 53, 79, 55, 142, 142, + 86, 91, 87, 94, 96, 94, 71, 94, 102, 102, + 94, 142, 77, 110, 148, 149, 81, 146, 142, 84, + 85, 86, 148, 88, 151, 90, 29, 92, 56, 57, + 95, -1, -1, -1, 99, 100, 101, -1, 126, 104, + 105, 123, 123, 108, 47, 48, 111, 112, 126, 128, + 53, 127, 55, 128, 119, 128, 128, -1, 129, 139, + -1, -1, 139, 146, 67, -1, -1, -1, 142, 47, + 48, -1, 75, 76, 142, 53, 79, 55, 142, 142, 83, 142, 142, 148, 149, 147, 152, 146, 146, 67, - 146, 146, 146, 146, 146, 152, -1, 75, 76, 148, + 146, 146, 146, 146, 151, -1, 148, 75, 76, 148, 128, 79, 148, 148, 148, 83, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, -1, 148, 148, 148, 148, 148, 148, 130, 148, 132, - 133, 134, 135, 136, 137, 138, 148, 148, 148, 152, + 133, 134, 135, 136, 137, 138, 148, 150, 149, 149, 149, 144, 145, 149, 149, 149, 154, 149, 151, 149, 153, 149, 130, 149, 132, 133, 134, 135, 136, 137, - 138, 149, 149, 149, 149, 149, 144, 145, 149, 149, - 152, 150, 155, 151, 150, 153, 150, 150, 150, 150, + 138, 149, 149, 149, 149, 149, 144, 145, 149, 151, + 150, 150, 155, 151, 150, 153, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, - 150, 150, 150, 150, 150, 150, -1, 151, 151, 151, + 150, 150, 150, 150, 150, -1, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - 151, 151, 151, 151, 151, 151, -1, 152, 152, 152, + 151, 151, -1, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, - 152, 152, 152, 152, -1, -1, 154, -1, 155, 155, + 152, 152, 152, -1, -1, 154, -1, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, 155, - 155, 155, -1, 156 + 155, -1, 156 ); protected $actionBase = array( - 0, 220, 295, 109, 109, 180, 703, -2, -2, -2, - -2, -2, 135, 473, 404, 505, 404, 574, 606, 675, - 675, 675, 330, 389, 221, 221, 816, 221, 328, 359, - 365, 225, 586, 513, 576, 398, 398, 398, 398, 134, - 134, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 398, 398, 398, 398, 398, 398, 398, 398, 398, - 398, 254, 179, 482, 460, 702, 704, 705, 706, 683, - 656, 727, 772, 773, 636, 774, 775, 776, 777, 778, - 771, 779, 757, 780, 418, 418, 418, 418, 418, 418, + 0, 220, 295, 109, 109, 180, 701, -2, -2, -2, + -2, -2, 135, 404, 505, 574, 505, 473, 606, 675, + 675, 675, 330, 389, 513, 513, 815, 225, 513, 328, + 359, 365, 586, 576, 221, 435, 435, 435, 435, 134, + 134, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 435, 435, 435, 435, 435, 435, 435, 435, 435, + 435, 254, 179, 482, 511, 700, 702, 703, 704, 811, + 651, 812, 771, 772, 610, 773, 774, 775, 776, 777, + 770, 778, 757, 779, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, -3, 354, 383, 413, 206, - 524, 618, 618, 618, 618, 618, 618, 618, 175, 175, + 524, 521, 521, 521, 521, 521, 521, 521, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, 175, - 175, 175, 175, 175, 175, 403, 521, 521, 521, 573, - 737, 496, 762, 762, 762, 762, 762, 762, 762, 762, + 175, 175, 175, 175, 175, 403, 618, 618, 618, 463, + 737, 603, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, 762, - 762, 762, 762, 762, 762, 470, -20, -20, 509, 608, - 327, 587, 210, 489, 197, 25, 25, 25, 25, 25, + 762, 762, 762, 762, 762, 470, -20, -20, 509, 639, + 327, 570, 210, 489, 197, 25, 25, 25, 25, 25, 17, 45, 5, 5, 5, 5, 712, 305, 305, 305, - 305, 118, 118, 118, 118, 795, 783, 782, 781, 303, - 303, 659, 659, 621, 735, 498, 498, 522, 522, 487, + 305, 118, 118, 118, 118, 794, 782, 781, 780, 303, + 303, 669, 669, 629, 734, 522, 522, 498, 498, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 387, - 156, 814, 130, 130, 130, 130, 243, 469, 207, 207, - 207, 643, 847, 243, 248, 248, 248, 476, 476, 476, - 76, 639, 296, 296, 547, 547, 547, 477, 477, 477, - 477, 483, 736, 638, 477, 477, 477, 362, 97, 334, - 648, 768, 657, 766, 508, 680, 96, 611, 681, 660, - 407, 569, 571, 561, 676, 406, 800, -6, 407, 254, - 532, 447, 630, 691, 408, 700, 268, 193, 363, 523, - 430, 232, 734, 699, 815, 758, 137, 321, 644, 630, - 630, 630, 13, 84, 731, 738, 430, 273, 570, 570, - 570, 570, 794, 609, 570, 570, 570, 570, 793, 769, - 38, 432, 770, 74, 701, 626, 626, 631, 631, 626, - 626, 626, 626, 647, 567, 626, 809, 802, 802, 631, - 640, 631, 647, 567, 811, 811, 811, 811, 631, 567, - 631, 631, 626, 631, 802, 802, 567, 621, 802, 427, - 567, 652, 626, 617, 617, 811, 695, 694, 631, 631, - 664, 802, 802, 802, 664, 567, 811, 615, 678, 67, - 802, 811, 623, 640, 623, 615, 567, 623, 640, 640, - 623, 54, 641, 633, 810, 813, 805, 760, 658, 624, - 804, 801, 812, 807, 803, 634, 682, 707, 708, 597, - 637, 646, 642, 628, 677, 635, 667, 660, 684, 622, - 622, 622, 665, 666, 665, 622, 622, 622, 622, 622, - 622, 622, 622, 839, 669, 672, 668, 629, 730, 619, - 688, 654, 610, 752, 612, 682, 682, 791, 820, 827, - 832, 732, 620, 800, 822, 665, 846, 698, 119, 599, - 798, 792, 687, 686, 665, 797, 665, 744, 665, 819, - 790, 682, 789, 622, 818, 845, 844, 843, 842, 841, - 840, 833, 838, 645, 837, 729, 653, 826, 168, 808, - 676, 663, 685, 728, 433, 836, 788, 665, 665, 742, - 736, 665, 740, 720, 696, 830, 718, 825, 835, 612, - 824, 665, 662, 834, 433, 533, 625, 674, 649, 717, - 806, 817, 799, 759, 572, 579, 787, 632, 716, 829, - 828, 831, 715, 756, 616, 755, 650, 786, 754, 796, - 714, 785, 767, 821, 651, 684, 679, 661, 655, 627, - 753, 784, 823, 713, 711, 710, 764, 709, 761, 0, + 156, 810, 130, 130, 130, 130, 243, 84, 207, 207, + 207, 663, 846, 243, 248, 248, 248, 476, 476, 476, + 76, 627, 296, 296, 545, 545, 545, 477, 477, 477, + 477, 483, 735, 644, 477, 477, 477, 430, 97, 434, + 620, 767, 648, 761, 508, 677, 96, 611, 657, 647, + 414, 569, 564, 543, 676, 406, 796, 407, 414, 254, + 523, 447, 626, 705, 432, 698, 193, 38, 343, 519, + 362, 137, 731, 696, 814, 813, 13, 665, 626, 626, + 626, 74, 348, 730, 736, 362, 273, 552, 552, 552, + 552, 793, 729, 552, 552, 552, 552, 792, 768, 408, + 268, 769, 232, 699, 638, 638, 642, 642, 638, 638, + 638, 638, 645, 630, 638, 805, 798, 798, 642, 641, + 642, 645, 630, 807, 807, 807, 807, 642, 630, 642, + 642, 638, 642, 798, 798, 630, 629, 798, 119, 630, + 662, 638, 652, 652, 807, 691, 688, 642, 642, 664, + 798, 798, 798, 664, 630, 807, 612, 678, 246, 798, + 807, 623, 641, 623, 612, 630, 623, 641, 641, 623, + 54, 632, 635, 806, 809, 801, 759, 659, 658, 800, + 797, 808, 803, 799, 605, 681, 706, 614, 579, 636, + 633, 617, 621, 679, 622, 661, 647, 682, 615, 615, + 615, 667, 616, 667, 615, 615, 615, 615, 615, 615, + 615, 615, 838, 666, 672, 668, 654, 728, 597, 687, + 656, 593, 744, 660, 681, 681, 790, 819, 826, 831, + 732, 631, 796, 821, 667, 845, 695, 168, 599, 758, + 791, 686, 685, 667, 683, 667, 742, 667, 818, 789, + 628, 788, 681, 787, 615, 817, 844, 843, 842, 841, + 840, 839, 832, 837, 637, 836, 720, 655, 825, 274, + 804, 676, 609, 684, 718, 433, 835, 786, 667, 667, + 740, 735, 667, 738, 717, 694, 829, 716, 824, 834, + 660, 823, 667, 646, 833, 433, 596, 625, 674, 619, + 715, 802, 816, 795, 756, 547, 536, 785, 634, 714, + 828, 827, 830, 713, 755, 468, 754, 650, 784, 753, + 613, 711, 766, 764, 820, 653, 682, 680, 643, 649, + 624, 752, 783, 822, 710, 709, 708, 760, 707, 727, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, - 134, -2, -2, -2, -2, 0, 0, 0, 0, 0, - -2, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 134, 134, -2, -2, -2, -2, 0, 0, 0, 0, + 0, -2, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, + 134, 134, 134, 134, 134, 134, 134, 134, 0, 0, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 0, 0, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, @@ -520,41 +521,40 @@ class Php5 extends \PhpParser\ParserAbstract 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 134, 134, 134, 134, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 418, -20, -20, -20, -20, 418, -20, - -20, -20, -20, -20, -20, -20, 418, 418, 418, 418, + 418, 418, 418, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 418, -20, -20, -20, -20, 418, + -20, -20, -20, -20, -20, -20, -20, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 418, -20, 418, 418, 418, -20, 487, -20, + 418, 418, 418, 418, -20, 418, 418, 418, -20, 487, + -20, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, - 487, 487, 487, 487, 487, 487, 487, 487, 487, 487, - 487, 487, 487, 418, 0, 0, 418, -20, 418, -20, - 418, -20, 418, 418, 418, 418, 418, 418, -20, -20, - -20, -20, -20, -20, 0, 248, 248, 248, 248, -20, - -20, -20, -20, 55, 55, 55, 55, 487, 487, 487, - 487, 487, 487, 248, 248, 476, 476, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 487, 55, 487, - 626, 626, 626, 626, 626, 296, 414, 414, 414, 296, - 296, 626, 0, 0, 0, 0, 0, 0, 626, 296, - 0, 0, 626, 626, 626, 626, 626, 626, 626, 626, - 414, 296, 626, 626, 626, 802, 0, 414, 550, 550, - 550, 550, 433, 430, 0, 626, 626, 640, 0, 0, - 0, 0, 802, 0, 631, 0, 0, 0, 0, 0, - 622, 119, 0, 246, 0, 0, 0, 0, 0, 0, - 620, 246, 322, 322, 0, 0, 645, 622, 622, 622, - 0, 0, 620, 620, 0, 0, 0, 0, 0, 0, - 274, 620, 0, 0, 0, 0, 274, 440, 0, 0, - 440, 0, 433 + 487, 487, 487, 487, 418, 0, 0, 418, -20, 418, + -20, 418, -20, 418, 418, 418, 418, 418, 418, -20, + -20, -20, -20, -20, -20, 0, 248, 248, 248, 248, + -20, -20, -20, -20, 55, 55, 55, 55, 487, 487, + 487, 487, 487, 487, 248, 248, 476, 476, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 487, 55, + 487, 638, 638, 638, 638, 638, 296, -6, -6, -6, + 296, 296, 638, 0, 0, 0, 0, 0, 0, 638, + 296, 0, 0, 638, 638, 638, 638, 638, 638, 638, + 638, -6, 296, 638, 638, 638, 798, 0, -6, 546, + 546, 546, 546, 433, 362, 0, 638, 638, 641, 0, + 0, 0, 0, 798, 0, 642, 0, 0, 0, 0, + 0, 615, 168, 0, 67, 0, 0, 0, 0, 0, + 0, 631, 67, 427, 427, 0, 637, 615, 615, 615, + 0, 0, 631, 631, 0, 0, 0, 0, 0, 0, + 322, 631, 0, 0, 0, 0, 322, 381, 0, 0, + 381, 0, 433 ); protected $actionDefault = array( 3,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767, 529, 529,32767, 484,32767,32767, + 32767,32767,32767,32767, 529, 529,32767,32767, 484,32767, 32767,32767,32767,32767,32767, 290, 290, 290,32767,32767, 32767, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,32767,32767,32767,32767,32767, 372,32767,32767, @@ -588,104 +588,104 @@ class Php5 extends \PhpParser\ParserAbstract 32767,32767,32767,32767,32767,32767,32767, 489,32767,32767, 32767,32767,32767,32767,32767, 502, 407,32767,32767, 400, 32767, 214, 216, 163, 475,32767,32767,32767,32767,32767, - 32767, 507, 334,32767,32767,32767,32767,32767, 543,32767, - 502,32767,32767,32767,32767,32767,32767,32767, 347, 326, - 327, 328,32767,32767,32767,32767, 506, 500, 459, 460, - 461, 462,32767,32767, 453, 454, 455, 458,32767,32767, + 32767, 507, 334,32767,32767,32767,32767,32767, 544,32767, + 502,32767,32767,32767,32767,32767,32767, 347, 326, 327, + 328,32767,32767,32767,32767, 506, 500, 459, 460, 461, + 462,32767,32767, 453, 454, 455, 458,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767, 167,32767, 415, 421, 421,32767,32767, + 32767,32767, 167,32767,32767,32767,32767,32767, 167,32767, + 32767,32767,32767, 505, 504, 167,32767, 401, 483, 167, + 180,32767, 178, 178,32767, 200, 200,32767,32767, 182, + 476, 495,32767, 182, 167,32767, 389, 169, 483,32767, + 32767, 232,32767, 232, 389, 167, 232,32767,32767, 232, + 32767, 83, 425,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 402,32767,32767,32767, 368, + 369, 478, 491,32767, 492,32767, 400,32767, 332, 333, + 335, 312,32767, 314, 358, 359, 360, 361, 362, 363, + 364, 366,32767,32767, 405, 408,32767,32767,32767, 85, + 110, 249,32767, 541, 85, 403,32767,32767, 297, 541, + 32767,32767,32767,32767, 536,32767,32767, 291,32767,32767, + 32767, 85, 85, 245,32767, 165,32767, 526,32767, 543, + 32767, 500, 404,32767, 331,32767,32767,32767,32767,32767, + 32767,32767,32767,32767, 501,32767,32767,32767,32767, 221, + 32767, 438,32767, 85,32767, 181,32767,32767, 295, 240, + 32767,32767, 535,32767,32767,32767,32767,32767,32767,32767, + 32767,32767, 166,32767,32767, 183,32767,32767, 500,32767, + 32767,32767,32767,32767,32767,32767, 286,32767,32767,32767, + 32767,32767, 500,32767,32767, 225,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 83, 60,32767, 267,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767, 167,32767, 415, 421, 421,32767, - 32767,32767,32767, 167,32767,32767,32767,32767,32767, 167, - 32767,32767,32767,32767, 505, 504, 167,32767, 401, 483, - 167, 180,32767, 178, 178,32767, 200, 200,32767,32767, - 182, 476, 495,32767, 182, 167,32767, 389, 169, 483, - 32767,32767, 232,32767, 232, 389, 167, 232,32767,32767, - 232,32767, 83, 425,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767, 402,32767,32767,32767, - 368, 369, 478, 491,32767, 492,32767, 400,32767, 332, - 333, 335, 312,32767, 314, 358, 359, 360, 361, 362, - 363, 364, 366,32767,32767, 405, 408,32767,32767,32767, - 85, 110, 249,32767, 541, 85, 403,32767,32767, 297, - 541,32767,32767,32767,32767, 536,32767,32767, 291,32767, - 32767,32767, 85, 85, 245,32767, 165,32767, 526,32767, - 500, 404,32767, 331,32767,32767,32767,32767,32767,32767, - 32767,32767,32767, 501,32767,32767,32767,32767, 221,32767, - 438,32767, 85,32767, 181,32767,32767, 295, 240,32767, - 32767, 535,32767,32767,32767,32767,32767,32767,32767,32767, - 32767, 166,32767,32767, 183,32767,32767, 500,32767,32767, - 32767,32767,32767,32767,32767, 286,32767,32767,32767,32767, - 32767, 500,32767,32767, 225,32767,32767,32767,32767,32767, - 32767,32767,32767,32767, 83, 60,32767, 267,32767,32767, - 32767,32767,32767,32767,32767,32767,32767,32767,32767, 123, - 123, 3, 123, 123, 3, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 208, 252, - 211, 200, 200, 160, 252, 252, 252, 259 + 123, 123, 3, 123, 123, 3, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 208, + 252, 211, 200, 200, 160, 252, 252, 252, 259 ); protected $goto = array( - 160, 160, 134, 134, 139, 134, 135, 136, 137, 142, + 160, 160, 134, 134, 139, 142, 134, 135, 136, 137, 144, 181, 162, 158, 158, 158, 158, 139, 139, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, - 154, 155, 156, 157, 178, 133, 179, 499, 500, 362, - 501, 505, 506, 507, 508, 509, 510, 511, 512, 966, + 154, 155, 156, 157, 178, 133, 179, 498, 499, 362, + 500, 504, 505, 506, 507, 508, 509, 510, 511, 967, 138, 140, 141, 143, 165, 170, 180, 196, 245, 248, 250, 252, 254, 255, 256, 257, 258, 259, 267, 268, - 269, 270, 285, 286, 314, 315, 316, 379, 380, 381, - 553, 182, 183, 184, 185, 186, 187, 188, 189, 190, + 269, 270, 285, 286, 314, 315, 316, 378, 379, 380, + 554, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 145, 146, 147, 161, 148, 163, - 149, 197, 164, 150, 151, 152, 198, 153, 131, 626, - 571, 757, 571, 571, 571, 571, 571, 571, 571, 571, + 149, 197, 164, 150, 151, 152, 198, 153, 131, 627, + 572, 758, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 572, 572, 572, 572, 572, + 572, 572, 572, 572, 572, 1105, 6, 1105, 1105, 1105, + 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, + 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, + 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, + 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, 1105, + 636, 889, 889, 1196, 1196, 528, 1174, 168, 1174, 514, + 757, 514, 171, 172, 173, 387, 388, 389, 390, 167, + 195, 199, 201, 249, 251, 253, 260, 261, 262, 263, + 264, 265, 271, 272, 273, 274, 287, 288, 317, 318, + 319, 393, 394, 395, 396, 169, 174, 246, 247, 175, + 176, 177, 502, 502, 502, 502, 502, 502, 553, 341, + 788, 577, 502, 502, 502, 502, 502, 502, 502, 502, + 502, 502, 513, 635, 513, 386, 612, 547, 547, 578, + 543, 585, 610, 794, 756, 545, 545, 501, 503, 534, + 551, 579, 582, 592, 598, 875, 515, 855, 515, 659, + 819, 516, 884, 879, 571, 859, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, 571, - 571, 571, 571, 571, 571, 1104, 756, 1104, 1104, 1104, - 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, - 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, - 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, - 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, 1104, - 635, 888, 888, 1195, 1195, 529, 6, 168, 1173, 515, - 1173, 515, 171, 172, 173, 388, 389, 390, 391, 167, - 195, 199, 201, 249, 251, 253, 260, 261, 262, 263, - 264, 265, 271, 272, 273, 274, 287, 288, 317, 318, - 319, 394, 395, 396, 397, 169, 174, 246, 247, 175, - 176, 177, 503, 503, 503, 503, 503, 503, 594, 344, - 404, 341, 503, 503, 503, 503, 503, 503, 503, 503, - 503, 503, 514, 787, 514, 387, 611, 548, 548, 577, - 544, 584, 609, 793, 755, 546, 546, 502, 504, 535, - 550, 578, 581, 591, 597, 874, 516, 854, 516, 658, - 634, 517, 883, 878, 570, 818, 570, 570, 570, 570, - 570, 570, 570, 570, 570, 570, 570, 570, 570, 570, - 570, 570, 570, 570, 570, 570, 570, 570, 570, 570, - 570, 570, 570, 570, 570, 570, 570, 570, 570, 570, - 570, 570, 570, 570, 570, 570, 570, 570, 570, 555, - 556, 557, 558, 559, 560, 561, 562, 564, 593, 323, - 312, 554, 520, 1165, 858, 528, 525, 525, 525, 451, - 453, 936, 637, 525, 906, 1105, 619, 934, 528, 528, - 1062, 1080, 1079, 438, 438, 438, 438, 438, 438, 543, - 525, 1199, 549, 438, 438, 438, 438, 438, 438, 438, - 438, 438, 438, 1069, 1153, 1069, 895, 895, 895, 895, - 895, 363, 601, 541, 780, 660, 566, 895, 598, 871, - 885, 616, 870, 617, 881, 621, 622, 629, 631, 636, - 638, 852, 852, 852, 852, 1172, 610, 1172, 847, 853, - 469, 780, 780, 1192, 1189, 1189, 1189, 525, 525, 964, - 375, 542, 572, 525, 525, 892, 356, 525, 1013, 901, - 1065, 1066, 1085, 533, 1062, 347, 552, 545, 1171, 576, - 1023, 17, 13, 355, 526, 342, 343, 1063, 1164, 1063, - 1206, 1206, 458, 398, 551, 776, 1064, 370, 370, 370, - 373, 565, 1206, 10, 944, 369, 1187, 1187, 1187, 773, - 773, 774, 21, 781, 781, 781, 783, 607, 910, 772, - 614, 370, 1205, 1205, 615, 1061, 623, 618, 386, 402, - 360, 587, 590, 632, 1205, 276, 277, 278, 1055, 646, - 784, 1060, 915, 454, 1208, 862, 582, 952, 1150, 467, - 0, 0, 0, 0, 540, 0, 0, 0, 0, 0, + 571, 571, 571, 571, 571, 571, 571, 571, 571, 556, + 557, 558, 559, 560, 561, 562, 563, 565, 594, 1081, + 1080, 555, 519, 907, 1166, 527, 524, 524, 524, 450, + 452, 937, 638, 524, 548, 1106, 620, 935, 527, 527, + 1200, 1063, 363, 437, 437, 437, 437, 437, 437, 542, + 524, 323, 312, 437, 437, 437, 437, 437, 437, 437, + 437, 437, 437, 1070, 602, 1070, 896, 896, 896, 896, + 896, 1154, 611, 540, 375, 661, 567, 896, 599, 872, + 886, 617, 871, 618, 882, 622, 623, 630, 632, 637, + 639, 853, 853, 853, 853, 781, 1206, 1206, 848, 854, + 468, 370, 370, 370, 945, 1193, 524, 524, 1206, 965, + 541, 573, 524, 524, 1207, 1207, 524, 1014, 1209, 1086, + 1066, 1067, 781, 781, 1063, 370, 1207, 1024, 17, 13, + 355, 893, 385, 525, 356, 342, 343, 1064, 1165, 1064, + 1173, 532, 1173, 552, 902, 544, 1065, 615, 566, 1190, + 1190, 1190, 1062, 624, 347, 397, 1188, 1188, 1188, 21, + 457, 777, 616, 369, 608, 619, 373, 911, 360, 775, + 647, 10, 401, 1172, 588, 591, 633, 1056, 916, 774, + 774, 785, 863, 782, 782, 782, 784, 953, 453, 773, + 595, 344, 403, 276, 277, 278, 1061, 583, 1151, 466, + 0, 0, 0, 0, 539, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 519, 539, 0, 0, 0, - 0, 0, 0, 534, 0, 0, 0, 519, 0, 539, - 0, 0, 0, 0, 0, 0, 518, 0, 523, 441, - 0, 443, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 779, 1213 + 0, 0, 0, 0, 518, 538, 0, 0, 0, 0, + 0, 0, 533, 0, 0, 0, 518, 0, 538, 0, + 0, 0, 0, 0, 0, 517, 0, 522, 440, 0, + 442, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 780, 1215 ); protected $gotoCheck = array( @@ -704,91 +704,91 @@ class Php5 extends \PhpParser\ParserAbstract 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, - 115, 115, 115, 115, 115, 122, 13, 122, 122, 122, + 115, 115, 115, 115, 115, 122, 92, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, 122, - 8, 72, 72, 72, 72, 96, 92, 25, 113, 115, - 113, 115, 25, 25, 25, 25, 25, 25, 25, 25, + 8, 72, 72, 72, 72, 96, 113, 25, 113, 115, + 13, 115, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, - 25, 25, 112, 112, 112, 112, 112, 112, 65, 65, - 65, 67, 112, 112, 112, 112, 112, 112, 112, 112, - 112, 112, 112, 27, 112, 49, 49, 49, 49, 49, + 25, 25, 112, 112, 112, 112, 112, 112, 2, 67, + 27, 2, 112, 112, 112, 112, 112, 112, 112, 112, + 112, 112, 112, 5, 112, 49, 49, 49, 49, 49, 49, 38, 38, 12, 12, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 12, 118, 12, 118, 12, - 5, 12, 12, 12, 55, 48, 55, 55, 55, 55, + 48, 12, 12, 12, 55, 31, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 105, - 105, 105, 105, 105, 105, 105, 105, 105, 105, 121, - 121, 45, 9, 77, 31, 45, 9, 9, 9, 7, - 7, 7, 7, 9, 79, 7, 7, 7, 45, 45, - 77, 120, 120, 55, 55, 55, 55, 55, 55, 9, - 9, 136, 104, 55, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 127, 55, 55, 55, 55, 55, - 55, 44, 123, 30, 21, 30, 30, 55, 30, 30, + 105, 105, 105, 105, 105, 105, 105, 105, 105, 120, + 120, 45, 9, 79, 77, 45, 9, 9, 9, 7, + 7, 7, 7, 9, 104, 7, 7, 7, 45, 45, + 136, 77, 44, 55, 55, 55, 55, 55, 55, 9, + 9, 121, 121, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 123, 55, 55, 55, 55, 55, + 55, 127, 47, 30, 46, 30, 30, 55, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, - 30, 55, 55, 55, 55, 114, 47, 114, 55, 55, - 55, 21, 21, 134, 114, 114, 114, 9, 9, 96, - 46, 9, 9, 9, 9, 74, 56, 9, 97, 76, - 77, 77, 32, 56, 77, 16, 2, 56, 114, 2, - 32, 32, 32, 32, 9, 67, 67, 77, 77, 77, - 138, 138, 56, 20, 9, 23, 77, 119, 119, 119, - 15, 32, 138, 56, 92, 10, 8, 8, 8, 21, - 21, 22, 32, 21, 21, 21, 21, 32, 80, 21, - 11, 119, 137, 137, 59, 11, 11, 59, 119, 19, - 59, 58, 58, 58, 137, 63, 63, 63, 108, 69, - 24, 110, 81, 61, 137, 66, 62, 94, 126, 103, + 30, 55, 55, 55, 55, 21, 137, 137, 55, 55, + 55, 119, 119, 119, 92, 134, 9, 9, 137, 96, + 9, 9, 9, 9, 138, 138, 9, 97, 137, 32, + 77, 77, 21, 21, 77, 119, 138, 32, 32, 32, + 32, 74, 119, 9, 56, 67, 67, 77, 77, 77, + 114, 56, 114, 9, 76, 56, 77, 11, 32, 114, + 114, 114, 11, 11, 16, 20, 8, 8, 8, 32, + 56, 23, 59, 10, 32, 59, 15, 80, 59, 22, + 69, 56, 19, 114, 58, 58, 58, 108, 81, 21, + 21, 24, 66, 21, 21, 21, 21, 94, 61, 21, + 65, 65, 65, 63, 63, 63, 110, 62, 126, 103, -1, -1, -1, -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 8, 8, -1, -1, -1, - -1, -1, -1, 96, -1, -1, -1, 8, -1, 8, - -1, -1, -1, -1, -1, -1, 8, -1, 8, 8, - -1, 8, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, 8 + -1, -1, -1, -1, 8, 8, -1, -1, -1, -1, + -1, -1, 96, -1, -1, -1, 8, -1, 8, -1, + -1, -1, -1, -1, -1, 8, -1, 8, 8, -1, + 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 8, 8 ); protected $gotoBase = array( - 0, 0, -175, 0, 0, 288, 0, 366, 188, 42, - 164, 47, 282, 154, 109, 143, 145, 0, 0, 113, - 158, 94, 153, 159, 111, 7, 0, 265, 0, 0, - -227, 346, 46, 0, 0, 0, 0, 0, 245, 0, - 0, -22, 0, 0, 373, 339, 160, 156, 289, -4, - 0, 0, 0, 0, 0, 104, 27, 0, 218, 50, - 0, 89, 82, -139, 0, -70, 114, -186, 0, 170, - 0, 0, -78, 0, 149, 0, 146, 26, 0, 351, - 150, 112, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 194, 0, 115, 0, 166, 157, 0, 0, - 0, 0, 0, 74, 367, 307, 0, 0, 110, 0, - 108, 0, -27, -91, 136, -90, 0, 0, -3, 179, - 72, 38, -45, 209, 0, 0, 79, 200, 0, 0, - 0, 0, 0, 0, 161, 0, 364, 201, 169, 0, - 0 + 0, 0, -384, 0, 0, 261, 0, 366, 188, 42, + 172, 25, 282, 208, 109, 159, 174, 0, 0, 107, + 170, 115, 161, 175, 103, 7, 0, 252, 0, 0, + -228, 287, 44, 0, 0, 0, 0, 0, 245, 0, + 0, -22, 0, 0, 344, 339, 124, 132, 284, -4, + 0, 0, 0, 0, 0, 104, 46, 0, 211, 39, + 0, 85, 84, -132, 0, 202, 102, -187, 0, 151, + 0, 0, -78, 0, 165, 0, 171, 27, 0, 340, + 149, 99, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 144, 0, 106, 0, 166, 156, 0, 0, + 0, 0, 0, 75, 349, 307, 0, 0, 100, 0, + 114, 0, -27, -93, 181, -90, 0, 0, -3, 133, + 50, 70, -45, 201, 0, 0, 80, 207, 0, 0, + 0, 0, 0, 0, 163, 0, 352, 125, 143, 0, + 0, 0 ); protected $gotoDefault = array( - -32768, 471, 669, 2, 670, 741, 749, 604, 485, 486, - 521, 522, 856, 794, 795, 365, 412, 487, 364, 399, - 392, 782, 775, 777, 785, 166, 400, 788, 1, 790, - 527, 826, 1014, 351, 798, 352, 596, 800, 537, 802, - 803, 132, 366, 367, 538, 488, 374, 585, 817, 266, - 371, 819, 353, 820, 829, 354, 468, 463, 567, 613, - 433, 450, 579, 275, 547, 574, 861, 340, 869, 649, - 877, 880, 489, 568, 891, 455, 899, 1090, 382, 905, - 911, 916, 919, 413, 401, 592, 923, 924, 5, 928, - 627, 628, 943, 300, 951, 605, 965, 418, 1033, 1035, - 490, 491, 531, 462, 513, 536, 492, 1056, 444, 403, - 1059, 493, 494, 434, 435, 1077, 1074, 346, 1158, 345, - 452, 311, 1145, 588, 1109, 459, 1198, 1154, 337, 495, - 496, 361, 1177, 376, 1193, 439, 1200, 1207, 333, 368, - 575 + -32768, 470, 670, 2, 671, 742, 750, 605, 484, 485, + 520, 521, 857, 795, 796, 365, 411, 486, 364, 398, + 391, 783, 776, 778, 786, 166, 399, 789, 1, 791, + 526, 827, 1015, 351, 799, 352, 597, 801, 536, 803, + 804, 132, 366, 367, 537, 487, 374, 586, 818, 266, + 371, 820, 353, 821, 830, 354, 467, 462, 568, 614, + 432, 449, 580, 275, 546, 575, 862, 340, 870, 650, + 878, 881, 488, 569, 892, 454, 900, 1091, 381, 906, + 912, 917, 920, 412, 400, 593, 924, 925, 5, 929, + 628, 629, 944, 300, 952, 606, 966, 417, 1034, 1036, + 489, 490, 530, 461, 512, 535, 491, 1057, 443, 402, + 1060, 492, 493, 433, 434, 1078, 1075, 346, 1159, 345, + 451, 311, 1146, 589, 1110, 458, 1199, 1155, 337, 494, + 495, 361, 1178, 376, 1194, 438, 1201, 1208, 333, 368, + 550, 576 ); protected $ruleToNonTerminal = array( @@ -846,8 +846,8 @@ class Php5 extends \PhpParser\ParserAbstract 131, 131, 131, 119, 119, 119, 119, 105, 105, 120, 120, 120, 120, 72, 133, 133, 134, 134, 134, 104, 104, 135, 135, 136, 136, 136, 136, 121, 121, 121, - 121, 138, 139, 137, 137, 137, 137, 137, 137, 137, - 140, 140, 140 + 121, 138, 139, 140, 137, 137, 137, 137, 137, 137, + 137, 141, 141, 141 ); protected $ruleToLength = array( @@ -905,8 +905,8 @@ class Php5 extends \PhpParser\ParserAbstract 6, 4, 4, 4, 4, 1, 4, 0, 1, 1, 3, 1, 1, 4, 3, 1, 1, 1, 0, 0, 2, 3, 1, 3, 1, 4, 2, 2, 2, 1, - 2, 1, 1, 1, 4, 3, 3, 3, 6, 3, - 1, 1, 1 + 2, 1, 1, 1, 1, 4, 3, 3, 3, 6, + 3, 1, 1, 1 ); protected function reduceRule0() { @@ -926,7 +926,7 @@ protected function reduceRule3() { } protected function reduceRule4() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; + $startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } @@ -1407,7 +1407,7 @@ protected function reduceRule123() { } protected function reduceRule124() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; + $startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } @@ -1548,7 +1548,7 @@ protected function reduceRule158() { } protected function reduceRule159() { - $startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; + $startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if ($this->useNopStatements && isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; if ($this->semValue === null) $this->semValue = array(); /* means: no statement */ } @@ -2510,21 +2510,7 @@ protected function reduceRule396() { } protected function reduceRule397() { - - if ($this->semStack[$this->stackPos-(2-1)] instanceof Node\Expr\StaticPropertyFetch) { - $this->semValue = new Expr\StaticCall($this->semStack[$this->stackPos-(2-1)]->class, new Expr\Variable($this->semStack[$this->stackPos-(2-1)]->name, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } elseif ($this->semStack[$this->stackPos-(2-1)] instanceof Node\Expr\ArrayDimFetch) { - $tmp = $this->semStack[$this->stackPos-(2-1)]; - while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { - $tmp = $tmp->var; - } - - $this->semValue = new Expr\StaticCall($tmp->var->class, $this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - $tmp->var = new Expr\Variable($tmp->var->name, $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); - } else { - throw new \Exception; - } - + $this->semValue = $this->fixupPhp5StaticPropCall($this->semStack[$this->stackPos-(2-1)], $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); } protected function reduceRule398() { @@ -3113,19 +3099,19 @@ protected function reduceRule542() { } protected function reduceRule543() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; + $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule544() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); + $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } protected function reduceRule545() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); } protected function reduceRule546() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); } protected function reduceRule547() { @@ -3133,22 +3119,26 @@ protected function reduceRule547() { } protected function reduceRule548() { - $this->semValue = new Expr\ArrayDimFetch(new Expr\Variable($this->semStack[$this->stackPos-(6-2)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(6-4)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); } protected function reduceRule549() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(6-2)], $this->semStack[$this->stackPos-(6-4)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); } protected function reduceRule550() { - $this->semValue = new Scalar\String_($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + $this->semValue = $this->semStack[$this->stackPos-(3-2)]; } protected function reduceRule551() { - $this->semValue = $this->parseNumString($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + $this->semValue = new Scalar\String_($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule552() { + $this->semValue = $this->parseNumString($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + } + + protected function reduceRule553() { $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } } diff --git a/lib/PhpParser/Parser/Php7.php b/lib/PhpParser/Parser/Php7.php index 97c55d6641..62e1b36116 100644 --- a/lib/PhpParser/Parser/Php7.php +++ b/lib/PhpParser/Parser/Php7.php @@ -19,15 +19,15 @@ class Php7 extends \PhpParser\ParserAbstract { protected $tokenToSymbolMapSize = 392; protected $actionTableSize = 886; - protected $gotoTableSize = 478; + protected $gotoTableSize = 477; protected $invalidSymbol = 157; protected $errorSymbol = 1; protected $defaultAction = -32766; protected $unexpectedTokenRule = 32767; - protected $YY2TBLSTATE = 337; - protected $YYNLSTATES = 566; + protected $YY2TBLSTATE = 336; + protected $YYNLSTATES = 567; protected $symbolToName = array( "EOF", @@ -233,95 +233,95 @@ class Php7 extends \PhpParser\ParserAbstract ); protected $action = array( - 571, 572, 573, 574, 575, 215, 576, 577, 578, 614, - 615, 477, 27, 99, 100, 101, 102, 103, 104, 105, + 572, 573, 574, 575, 576, 215, 577, 578, 579, 615, + 616, 478, 27, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,-32766,-32766,-32766, 95, 96, - 97, 116, 239, 0, -269,-32766,-32766,-32766, -474, -473, - 1055, 648, 1058, 1056, 98,-32766, 275,-32766,-32766,-32766, - -32766,-32766, 579, 875, 877,-32766,-32766,-32766,-32766,-32766, - -32766,-32766,-32766, 224,-32766, 718, 580, 581, 582, 583, - 584, 585, 586,-32766, 241, 646, 844, 845, 846, 843, - 842, 841, 587, 588, 589, 590, 591, 592, 593, 594, - 595, 596, 597, 617, 618, 619, 620, 621, 609, 610, - 611, 612, 613, 598, 599, 600, 601, 602, 603, 604, - 640, 641, 642, 643, 644, 645, 605, 606, 607, 608, - 638, 629, 627, 628, 624, 625, 768, 616, 622, 623, - 630, 631, 633, 632, 634, 635, 42, 43, 389, 44, - 45, 626, 637, 636, -216, 46, 47, 957, 48,-32767, - -32767,-32767,-32767, 90, 91, 92, 93, 94, 269, 347, - 22, 844, 845, 846, 843, 842, 841, 836,-32766,-32766, - -32766, 1047, 1007, 350, 1046, 120, 973, 441, -427, 248, - 801, 49, 50, -474, -473, -474, -473, 51,-32766, 52, + 97, 275, 239, 0, -269,-32766,-32766,-32766, -473, -474, + 1057, 649, 1060, 1058, 98,-32766, 25,-32766,-32766,-32766, + -32766,-32766, 580, 876, 878,-32766,-32766,-32766,-32766,-32766, + -32766,-32766,-32766, 224,-32766, 719, 581, 582, 583, 584, + 585, 586, 587,-32766, 116, 647, 845, 846, 847, 844, + 843, 842, 588, 589, 590, 591, 592, 593, 594, 595, + 596, 597, 598, 618, 619, 620, 621, 622, 610, 611, + 612, 613, 614, 599, 600, 601, 602, 603, 604, 605, + 641, 642, 643, 644, 645, 646, 606, 607, 608, 609, + 639, 630, 628, 629, 625, 626, 769, 617, 623, 624, + 631, 632, 634, 633, 635, 636, 42, 43, 388, 44, + 45, 627, 638, 637, -216, 46, 47, 958, 48,-32767, + -32767,-32767,-32767, 90, 91, 92, 93, 94, 269, 440, + 22, 845, 846, 847, 844, 843, 842, 837,-32766,-32766, + -32766, 1048, 1008, 349, 1047, 120, 974, 346, -428, 248, + 802, 49, 50, -473, -474, -473, -474, 51,-32766, 52, 219, 220, 53, 54, 55, 56, 57, 58, 59, 60, - 1025, 22, 232, 61, 355, 950,-32766,-32766,-32766, 974, - 975, 649, 709, 1007, 28, -463, 125, 973,-32766,-32766, - -32766, 719, 403, 404, 366, 1007,-32766, 539,-32766,-32766, - -32766,-32766, 25, 222, 987, 286, 363, 24,-32766, -427, - -32766,-32766,-32766, 1010, 65, 769, 413, 266, -164, 258, - 1007, 226, 248, -427, 401, 402, 216, 521, 950, 276, - -427, 124, -430, 403, 404, 111, 979, 980, 981, 982, - 976, 977, 243, 112, -428, -426, 648, 414, 983, 978, - 360, 795, 796, 128, 969, 63, 130, 255, 351, 256, - 258, 390, -124, -124, -124, -4, 719, 391, 649, 1052, - -426, 708, 258, -221, 33, 17, 392, -124, 393, -124, - 394, -124, 395, -124, 663, 396, -124, -124, -124, 34, - 35, 356, 357, 522, 36, 397, 360, 258, 62, 117, - 822, 287, 288, 398, 399, -428, -426, 118, -163, 400, - 38, 40, 694, 739, 358, 359, -240, 22, 122, -428, - -426,-32766,-32766,-32766, 795, 796, -428, -426, -431, 1007, - -463, -426, 1007, 973, 414, 21, 390, 360, 721, 537, - -124,-32766, 391,-32766,-32766, -426, 708, 664, 665, 33, - 17, 392, -426, 393, 41, 394, -465, 395, 354, 291, - 396, 71, 950, -164, 34, 35, 356, 357, 339, 36, - 397, 246, 247, 62, 254, 719, 287, 288, 398, 399, - 404,-32766,-32766,-32766, 400, 957, 290, 656, 739, 358, - 359, 341, 113, 115, 352, 376, 72, 73, 74, 706, - 353, 65, 121, 543, 224, 242, 258, 259, 272, 258, - 92, 93, 94, 721, 537, -4, 26, 7, 75, 76, + 1026, 22, 232, 61, 354, 951,-32766,-32766,-32766, 975, + 976, 650, 710, 1008, 216, -463, 988, 974,-32766,-32766, + -32766, 720, 402, 403, 365, 1008,-32766, 540,-32766,-32766, + -32766,-32766, 24, 222,-32766,-32766, 362, 286,-32766, -428, + -32766,-32766,-32766, 1011, 65, 770, 412, 266, -164, 258, + 1008, 226, 248, -428, 400, 401, 241, 522, 951, 28, + -428, 718, -431, 402, 403, 128, 980, 981, 982, 983, + 977, 978, 243, 131, -427, -426, 649, 413, 984, 979, + 359, 796, 797, 118, 970, 63, 112, 255, 7, 256, + 258, 389, -124, -124, -124, -4, 720, 390, 650, 117, + 40, 709, 258, -221, 33, 17, 391, -124, 392, -124, + 393, -124, 394, -124, 664, 395, -124, -124, -124, 34, + 35, 355, 356, 523, 36, 396, 359, 258, 62, 111, + 823, 287, 288, 397, 398, -427, -426, 130, 351, 399, + 38, -426, 695, 740, 357, 358, -240, 22, 122, -427, + -426,-32766,-32766,-32766, 796, 797, -427, -426, -430, 1008, + -463, 247, 1008, 974, 413, 41, 389, 359, 722, 538, + -124,-32766, 390,-32766,-32766, 290, 709, 665, 666, 33, + 17, 391, 115, 392, 21, 393, 353, 394, -465, 350, + 395, 71, 951, -164, 34, 35, 355, 356, 338, 36, + 396, 246, -426, 62, 254, 720, 287, 288, 397, 398, + 403,-32766,-32766,-32766, 399, 958, -426, 657, 740, 357, + 358, 340, 113, -426, -163, 375, 72, 73, 74, 819, + 352, 65, 121, 544, 224, 124, 258, 259, 272, 258, + 92, 93, 94, 722, 538, -4, 26, 291, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, - 97, 131, 239, 717, 719, 390, 554,-32766,-32766,-32766, - 549, 391, 114, -163, 98, 708,-32766,-32766, 33, 17, - 392, -240, 393, 1007, 394, -82, 395, 126, 370, 396, - 497, 18, 544, 34, 35, 356, 719, 225, 36, 397, - 802, 119, 62, 508, 509, 287, 288, 127, 298, 493, - 494, 384, 6, 400, 664, 665, 950, 795, 796, 1026, - 705, -465, 223, 943, 541, 821, 565, 348, 833, 555, - 657, 540, 221, 732, 390, 377, 120, 239, 39, 98, - 391, 516, 755, 537, 708, 849, 650, 33, 17, 392, - 1057, 393, 648, 394, 649, 395, 316, 502, 396, 16, - 258, 817, 34, 35, 356, 719, 390, 36, 397, 652, - 445, 62, 391,-32766, 287, 288, 708, 517, 818, 33, - 17, 392, 400, 393, 364, 394, 450, 395, 498, 503, - 396, 531, 512, 542, 34, 35, 356, 719, -80, 36, - 397, 214, 369, 62, 10, 274, 287, 288, 492, 662, - 267, 721, 537, 271, 400, 740, 268, 741, 3, 989, - 986, 734, 0, 0, 0, 550, 0, -385, 0, 0, - 0, 0, 0, 0, 0, 390, 0, 0, 0, 0, - 0, 391, 0, 721, 537, 708, 227, 9, 33, 17, - 392, 289, 393, 0, 394, 264, 395, 321, 326, 396, - 342, 447, 322, 34, 35, 356, 719, 390, 36, 397, - 366, 310, 62, 391, 343, 287, 288, 708, 22, 702, - 33, 17, 392, 400, 393, 564, 394, 563, 395, 32, - 1007, 396, 703, 716, 973, 34, 35, 356, 31, 704, - 36, 397, 710, 699, 62, 771, 825, 287, 288, 661, - 660, 756, 721, 537, 762, 400, 763, 697, 753, 827, - 751, 829, 828, 950, 826, 715, 707, 250, 265, 337, - 338, 561, 560, 538, 545, 547, 390, 548, 552, 553, - 403, 404, 391, 556, 721, 537, 708, 558, 340, 33, - 17, 392, 659, 393, 1054, 394, 658, 395, 695, 834, - 396, 270, 65, 1053, 34, 35, 356, 258, 728, 36, - 397, 937, 667, 62, 666, 735, 287, 288,-32766,-32766, - -32766, 938, 761, 669, 400, 668, 1051, 1008, 1001, 1015, - 1020, 1023, 760, 939, 736, 557, 737, 738,-32766, 726, + 97, -82, 239, 242, 720, 389, 555,-32766,-32766,-32766, + 550, 390, 114, 16, 98, 709, 127, 298, 33, 17, + 391, -240, 392, 1008, 393, 126, 394, 119, 369, 395, + 498, 18, 545, 34, 35, 355, 720, 276, 36, 396, + 1027, 733, 62, 509, 510, 287, 288, 383, 6, 494, + 495, 665, 666, 399, 796, 797, 951, 225, 223, 803, + 707, 944, 221, -465, 551, 658, 541, 347, 822, 566, + 834, 556, 239, 98, 389, 376, 120, 39, 125, 517, + 390, 850, 756, 538, 709, 651, 650, 33, 17, 391, + 649, 392, 461, 393, 653, 394, 1059, 504, 395, -163, + 258, 818, 34, 35, 355, 720, 389, 36, 396, 532, + -32766, 62, 390, 444, 287, 288, 709, 499, 706, 33, + 17, 391, 399, 392, 449, 393, 503, 394, 518, 271, + 395, 363, 513, 542, 34, 35, 355, 720, 214, 36, + 396, -80, 10, 62, 368, 565, 287, 288, 493, 742, + 274, 722, 538, 932, 399, 741, 990, 0, 325, 0, + 267, 0, 0, 3, 987, 543, 0, 268, 0, 0, + 0, 0, 0, 0, 0, 389, 0, 0, 0, 0, + 0, 390, 0, 722, 538, 709, 227, 9, 33, 17, + 391, 289, 392, -385, 393, 264, 394, 497, 320, 395, + 321, 341, 365, 34, 35, 355, 720, 389, 36, 396, + 342, 310, 62, 390, 446, 287, 288, 709, 22, 735, + 33, 17, 391, 399, 392, 564, 393, 663, 394, 32, + 1008, 395, 827, 31, 974, 34, 35, 355, 703, 704, + 36, 396, 717, 705, 62, 829, 716, 287, 288, 826, + 662, 661, 722, 538, 700, 399, 772, 757, 763, 764, + 828, 698, 754, 951, 752, 830, 711, 708, -397, 265, + 336, 337, 562, 561, 559, 539, 389, 546, 548, 549, + 402, 403, 390, 553, 722, 538, 709, 554, 557, 33, + 17, 391, 660, 392, 1056, 393, 1054, 394, 835, 696, + 395, 339, 65, 659, 34, 35, 355, 258, 1055, 36, + 396, 729, 938, 62, 668, 667, 287, 288,-32766,-32766, + -32766, 736, 727, 762, 399, 670, 669, 1053, 1009, 1002, + 1016, 1021, 1024, 761, 940, 737, 558, 738,-32766, 739, -32766,-32766,-32766,-32766,-32766,-32766,-32767,-32767,-32767,-32767, - -32767, 238, 237, 721, 537, 236, 931, 235, 218, 217, - 132, 129, 123, 346, -453, -431, 70, -430, 69, 68, - -429, 20, -455, 67, 23, 29, 66, 64, 37, 30, - 0, 297, 19, 15, 11, 488, 530, -219, 918, 915, - 914, 475, -217, 470, 971, 961, 527, 387, 383, 382, - 378, 14, 13, 12, -216, 0, -397, 0, 496, 1014, - 1049, 999, 1000, 970, 0, 988 + -32767, 939, 250, 722, 538, 270, 1015, 238, 237, 236, + 235, 218, 217, 132, 129, 123, 345, -453, -431, 70, + -430, 69, 68, -429, 20, -455, 67, 23, 29, 66, + 64, 37, 30, 0, 297, 19, 15, 11, 489, 531, + -219, 919, 916, 915, 476, -217, 471, 972, 962, 528, + 386, 382, 381, 377, 14, 13, 12, -216, 0, 0, + 1051, 1000, 1001, 971, 0, 989 ); protected $actionCheck = array( @@ -340,21 +340,21 @@ class Php7 extends \PhpParser\ParserAbstract 122, 123, 124, 125, 126, 127, 29, 129, 130, 131, 132, 133, 134, 135, 136, 137, 2, 3, 4, 5, 6, 143, 144, 145, 152, 11, 12, 1, 14, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 109, 7, + 42, 43, 44, 45, 46, 47, 48, 49, 109, 82, 67, 112, 113, 114, 115, 116, 117, 118, 8, 9, - 10, 79, 79, 7, 82, 147, 83, 82, 67, 28, + 10, 79, 79, 7, 82, 147, 83, 7, 67, 28, 152, 47, 48, 152, 152, 154, 154, 53, 28, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 1, 67, 68, 69, 70, 112, 8, 9, 10, 75, - 76, 77, 148, 79, 13, 7, 67, 83, 8, 9, + 76, 77, 148, 79, 13, 7, 139, 83, 8, 9, 10, 1, 129, 130, 146, 79, 28, 149, 30, 31, - 32, 33, 140, 141, 139, 7, 102, 7, 28, 128, + 32, 33, 140, 141, 8, 9, 102, 7, 28, 128, 30, 31, 32, 1, 151, 148, 112, 7, 7, 156, - 79, 7, 28, 142, 120, 121, 13, 77, 112, 33, - 149, 15, 151, 129, 130, 15, 132, 133, 134, 135, + 79, 7, 28, 142, 120, 121, 7, 77, 112, 13, + 149, 29, 151, 129, 130, 15, 132, 133, 134, 135, 136, 137, 138, 15, 67, 67, 77, 143, 144, 145, 146, 130, 131, 15, 1, 151, 15, 153, 7, 155, - 156, 71, 72, 73, 74, 0, 1, 77, 77, 150, + 156, 71, 72, 73, 74, 0, 1, 77, 77, 15, 67, 81, 156, 152, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 148, 95, 96, 97, 98, 99, 100, 101, 102, 143, 104, 105, 146, 156, 108, 15, @@ -368,58 +368,58 @@ class Php7 extends \PhpParser\ParserAbstract 105, 128, 128, 108, 109, 1, 111, 112, 113, 114, 130, 8, 9, 10, 119, 1, 142, 122, 123, 124, 125, 146, 149, 149, 7, 29, 8, 9, 10, 148, - 7, 151, 149, 29, 35, 29, 156, 67, 143, 156, + 7, 151, 149, 29, 35, 15, 156, 67, 143, 156, 47, 48, 49, 148, 149, 150, 28, 7, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - 52, 15, 54, 29, 1, 71, 29, 8, 9, 10, - 29, 77, 13, 152, 66, 81, 8, 9, 84, 85, + 52, 29, 54, 29, 1, 71, 29, 8, 9, 10, + 29, 77, 13, 152, 66, 81, 97, 98, 84, 85, 86, 152, 88, 79, 90, 29, 92, 29, 128, 95, - 72, 73, 29, 99, 100, 101, 1, 35, 104, 105, - 152, 29, 108, 72, 73, 111, 112, 97, 98, 106, - 107, 102, 103, 119, 102, 103, 112, 130, 131, 152, + 72, 73, 29, 99, 100, 101, 1, 33, 104, 105, + 152, 35, 108, 72, 73, 111, 112, 102, 103, 106, + 107, 102, 103, 119, 130, 131, 112, 35, 35, 152, 148, 152, 35, 152, 29, 148, 149, 123, 148, 149, - 148, 149, 35, 35, 71, 149, 147, 54, 67, 66, - 77, 74, 148, 149, 81, 79, 77, 84, 85, 86, - 80, 88, 77, 90, 77, 92, 78, 93, 95, 152, - 156, 148, 99, 100, 101, 1, 71, 104, 105, 79, - 82, 108, 77, 82, 111, 112, 81, 91, 148, 84, - 85, 86, 119, 88, 102, 90, 86, 92, 87, 96, - 95, 89, 96, 29, 99, 100, 101, 1, 94, 104, - 105, 94, 94, 108, 94, 126, 111, 112, 109, 148, - 126, 148, 149, 110, 119, 123, 127, 123, 142, 139, - 139, 147, -1, -1, -1, 29, -1, 142, -1, -1, + 148, 149, 54, 66, 71, 149, 147, 67, 67, 74, + 77, 79, 148, 149, 81, 77, 77, 84, 85, 86, + 77, 88, 78, 90, 79, 92, 80, 96, 95, 152, + 156, 148, 99, 100, 101, 1, 71, 104, 105, 89, + 82, 108, 77, 82, 111, 112, 81, 87, 148, 84, + 85, 86, 119, 88, 86, 90, 93, 92, 91, 110, + 95, 102, 96, 29, 99, 100, 101, 1, 94, 104, + 105, 94, 94, 108, 94, 148, 111, 112, 109, 123, + 126, 148, 149, 153, 119, 123, 139, -1, 146, -1, + 126, -1, -1, 142, 139, 29, -1, 127, -1, -1, -1, -1, -1, -1, -1, 71, -1, -1, -1, -1, -1, 77, -1, 148, 149, 81, 35, 142, 84, 85, - 86, 142, 88, -1, 90, 149, 92, 146, 146, 95, + 86, 142, 88, 142, 90, 149, 92, 154, 146, 95, 146, 146, 146, 99, 100, 101, 1, 71, 104, 105, - 146, 146, 108, 77, 146, 111, 112, 81, 67, 148, + 146, 146, 108, 77, 146, 111, 112, 81, 67, 147, 84, 85, 86, 119, 88, 148, 90, 148, 92, 148, 79, 95, 148, 148, 83, 99, 100, 101, 148, 148, 104, 105, 148, 148, 108, 148, 148, 111, 112, 148, 148, 148, 148, 149, 148, 119, 148, 148, 148, 148, - 148, 148, 148, 112, 148, 148, 148, 152, 149, 149, + 148, 148, 148, 112, 148, 148, 148, 148, 153, 149, 149, 149, 149, 149, 149, 149, 71, 149, 149, 149, - 129, 130, 77, 149, 148, 149, 81, 149, 151, 84, + 129, 130, 77, 149, 148, 149, 81, 149, 149, 84, 85, 86, 150, 88, 150, 90, 150, 92, 150, 150, 95, 151, 151, 150, 99, 100, 101, 156, 150, 104, 105, 150, 150, 108, 150, 150, 111, 112, 8, 9, 10, 150, 150, 150, 119, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 28, 150, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 151, 151, 148, 149, 151, 153, 151, 151, 151, + 40, 150, 152, 148, 149, 151, 154, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, 151, - -1, 152, 152, 152, 152, 152, 152, 152, 152, 152, + 151, 151, 151, -1, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, - 152, 152, 152, 152, 152, -1, 153, -1, 154, 154, + 152, 152, 152, 152, 152, 152, 152, 152, -1, -1, 154, 154, 154, 154, -1, 155 ); protected $actionBase = array( - 0, 220, 295, 283, 180, 581, -2, -2, -2, -2, - -36, 574, 473, 606, 473, 505, 404, 675, 675, 675, - 28, 399, 507, 507, 507, 488, 482, 497, 472, 134, + 0, 220, 295, 283, 180, 582, -2, -2, -2, -2, + -36, 606, 473, 505, 473, 574, 404, 675, 675, 675, + 28, 399, 497, 497, 484, 497, 468, 493, 492, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, @@ -430,53 +430,54 @@ class Php7 extends \PhpParser\ParserAbstract 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 97, 64, 201, 587, 585, 706, 711, - 701, 702, 517, 699, 707, 243, 646, 647, 468, 648, - 649, 650, 651, 703, 724, 700, 704, 418, 418, 418, + 134, 134, 134, 97, 64, 246, 568, 670, 709, 714, + 704, 705, 514, 702, 710, 201, 647, 648, 466, 649, + 650, 651, 652, 706, 513, 703, 707, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 418, 48, 469, 478, 403, 403, 403, 403, + 418, 418, 418, 48, 469, 226, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 403, 160, 160, 160, 343, 210, - 208, 198, 17, 233, 27, 780, 780, 780, 780, 780, + 208, 198, 17, 274, 27, 780, 780, 780, 780, 780, 108, 108, 108, 108, 621, 621, 93, 280, 280, 280, - 280, 280, 280, 280, 280, 280, 280, 280, 657, 656, - 654, 653, 414, 393, 393, 151, 151, 151, 151, 146, - -45, 224, 224, 95, 490, 730, 199, 199, 397, 207, - 111, -22, -22, -22, 275, 498, 92, 92, 242, -37, - 233, 233, 274, 233, 422, 422, 422, 221, 221, 221, - 221, 221, 78, 501, 221, 221, 221, 503, 652, 387, - 506, 642, 273, 31, 32, 524, 538, 171, 492, 171, - 171, 171, 413, 428, 441, 495, 676, 396, 97, 226, - 390, 493, 588, 166, 572, 382, 281, 370, 392, 417, - 516, 571, 709, 331, 708, 377, 149, 493, 493, 493, - 358, 589, 590, 339, -8, 645, 591, 241, 419, 379, - 643, 634, 423, 632, 440, 381, 568, 487, 487, 485, - 485, 487, 487, 487, 487, 476, 508, 487, 690, 690, - 485, 500, 485, 476, 508, 697, 485, 508, 485, 485, - 487, 485, 690, 508, 508, 494, 487, 489, 489, 485, - 485, 499, 690, 690, 499, 508, 549, 547, 509, 484, - 406, 500, 406, 509, 508, 406, 500, 406, 33, 696, - 695, 466, 692, 694, 688, 607, 687, 594, 502, 504, - 678, 677, 685, 698, 693, 444, 525, 471, 250, 258, - 486, 481, 689, 492, 534, 483, 483, 483, 481, 684, - 483, 483, 483, 483, 483, 483, 483, 483, 729, 230, - 519, 510, 541, 554, 555, 314, 561, 535, 518, 322, - 604, 491, 525, 525, 618, 723, 673, 479, 676, 713, - 681, 560, 24, 246, 674, 655, 521, 526, 671, 608, - 250, 712, 614, 525, 612, 483, 683, 691, 727, 728, - 686, 725, 718, 67, 522, 564, 39, 480, 726, 616, - 593, 592, 551, 721, 705, 717, 716, 39, 565, 511, - 710, 474, 682, 620, 595, 268, 623, 680, 567, 720, - 719, 722, 573, 576, 596, 271, 598, 456, 679, 451, - 477, 496, 578, 628, 599, 670, 579, 580, 631, 635, - 714, 514, 534, 515, 513, 520, 512, 600, 641, 715, - 447, 582, 583, 584, 659, 586, 619, 0, 0, 0, + 280, 280, 280, 280, 280, 280, 280, 280, 659, 657, + 655, 654, 414, 393, 393, 151, 151, 151, 151, 146, + -45, 224, 224, 77, 487, 730, 199, 199, 394, 111, + 207, -22, -22, -22, 275, 501, 92, 92, 242, -37, + 274, 274, 233, 274, 419, 419, 419, 221, 221, 221, + 221, 221, 78, 498, 221, 221, 221, 471, 653, 390, + 506, 643, 273, 32, 31, 525, 534, 171, 499, 171, + 171, 171, 413, 428, 441, 521, 679, 396, 97, 474, + 392, 488, 589, 166, 573, 440, 382, 370, 387, 331, + 516, 572, 712, 417, 711, 358, 488, 488, 488, 377, + 590, 591, 339, -8, 646, 592, 241, 415, 381, 645, + 635, 423, 634, 281, 379, 571, 479, 479, 483, 483, + 479, 479, 479, 479, 472, 476, 479, 693, 693, 483, + 485, 483, 472, 476, 700, 483, 476, 483, 483, 479, + 483, 693, 476, 476, 504, 479, 494, 494, 483, 483, + 510, 693, 693, 510, 476, 547, 467, 509, 542, 444, + 485, 444, 509, 476, 444, 485, 444, 33, 699, 698, + 442, 695, 697, 691, 620, 690, 596, 502, 496, 681, + 680, 688, 701, 696, 232, 538, 549, 314, 271, 491, + 480, 692, 499, 526, 477, 477, 477, 480, 687, 477, + 477, 477, 477, 477, 477, 477, 477, 729, 39, 519, + 508, 560, 561, 564, 284, 565, 535, 520, 268, 609, + 495, 538, 538, 619, 585, 470, 478, 679, 716, 684, + 555, 67, 420, 678, 656, 522, 524, 677, 595, 314, + 715, 616, 481, 614, 538, 612, 477, 686, 694, 727, + 728, 689, 672, 721, 249, 482, 588, 24, 486, 726, + 623, 594, 593, 551, 724, 708, 720, 719, 24, 576, + 500, 713, 503, 685, 674, 598, 250, 628, 683, 578, + 723, 722, 725, 579, 580, 599, 322, 600, 258, 682, + 451, 475, 507, 581, 631, 604, 676, 583, 584, 632, + 641, 717, 517, 526, 515, 489, 518, 490, 608, 671, + 718, 447, 586, 587, 567, 642, 554, 618, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 134, 134, -2, - -2, -2, 0, 0, 0, 0, -2, 134, 134, 134, + 0, 0, 0, 0, 0, 0, 0, 0, 134, 134, + -2, -2, -2, 0, 0, 0, 0, -2, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, 134, - 134, 134, 134, 134, 134, 0, 0, 0, 0, 0, + 134, 134, 134, 134, 134, 134, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -486,34 +487,33 @@ class Php7 extends \PhpParser\ParserAbstract 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 418, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 418, + 418, 418, 418, 418, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 418, 418, 418, 418, -3, 418, 418, -3, - 418, 418, 418, 418, 418, 418, -22, -22, -22, -22, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 49, 49, 49, 49, 221, -22, - -22, 221, 221, 221, 221, 221, 49, 221, 221, 92, - 92, 92, 171, 171, 221, 0, 0, 0, 0, 0, - 487, 92, 0, 0, 171, 0, 0, 0, 0, 0, - 487, 487, 487, 0, 0, 0, 0, 0, 487, 92, - 0, 0, 0, 420, 420, 39, 420, 420, 0, 0, - 0, 487, 487, 0, 500, 0, 0, 0, 0, 0, - 0, 690, 485, 0, 0, 500, 0, 483, 24, 0, - 228, 0, 0, 0, 0, 0, 479, 228, 244, 0, - 244, 0, 0, 483, 483, 483, 0, 479, 479, 0, - 0, 240, 479, 0, 0, 0, 240, 152, 0, 152, - 0, 0, 39 + 418, 418, 418, 418, 418, 418, 418, -3, 418, 418, + -3, 418, 418, 418, 418, 418, 418, -22, -22, -22, + -22, 221, 221, 221, 221, 221, 221, 221, 221, 221, + 221, 221, 221, 221, 221, 49, 49, 49, 49, 221, + -22, -22, 221, 221, 221, 221, 221, 49, 221, 221, + 92, 92, 92, 171, 171, 221, 0, 0, 0, 0, + 0, 479, 92, 0, 0, 171, 0, 0, 0, 0, + 0, 479, 479, 479, 0, 0, 0, 0, 0, 479, + 92, 0, 0, 0, 389, 389, 24, 389, 389, 0, + 0, 0, 479, 479, 0, 485, 0, 0, 0, 0, + 0, 0, 693, 483, 0, 0, 485, 0, 477, 67, + 0, 230, 0, 0, 0, 0, 0, 478, 230, 244, + 0, 244, 0, 477, 477, 477, 0, 478, 478, 0, + 0, 240, 478, 0, 0, 0, 240, 170, 0, 170, + 0, 0, 24 ); protected $actionDefault = array( 3,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767, 475, 475, 475,32767,32767,32767,32767, 288, + 32767,32767, 475, 475,32767, 475,32767,32767,32767, 288, 467, 288, 288,32767, 424, 424, 424, 424, 424, 424, 424, 467,32767,32767,32767,32767,32767, 367,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, @@ -541,84 +541,84 @@ class Php7 extends \PhpParser\ParserAbstract 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, 32767,32767, 393, 426, 426,32767,32767,32767, 384,32767, 32767,32767, 161, 212, 214, 401,32767,32767,32767,32767, - 32767, 332,32767,32767,32767,32767,32767, 482,32767,32767, - 32767,32767,32767, 426,32767,32767,32767, 324, 325, 326, - 32767,32767,32767, 426, 426,32767,32767, 426,32767, 426, + 32767, 332,32767,32767,32767,32767,32767, 483,32767,32767, + 32767,32767,32767, 426,32767,32767, 324, 325, 326,32767, + 32767,32767, 426, 426,32767,32767, 426,32767, 426,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767, 165,32767, 399, 399, - 32767,32767,32767,32767, 165, 394,32767, 165,32767,32767, - 32767,32767,32767, 165, 165, 178,32767, 176, 176,32767, - 32767, 180,32767, 440, 180, 165, 198, 198, 376, 167, - 233,32767, 233, 376, 165, 233,32767, 233,32767,32767, - 32767, 83,32767,32767,32767,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767, 386,32767,32767, 406, - 32767, 419, 438, 384,32767, 330, 331, 333,32767, 428, - 355, 356, 357, 358, 359, 360, 361, 363,32767, 468, - 389,32767,32767,32767,32767,32767,32767, 85, 110, 247, - 32767, 480, 85, 387,32767, 480,32767,32767,32767,32767, - 32767,32767, 289,32767,32767,32767, 85, 85,32767,32767, - 464,32767, 426, 388,32767, 329, 402, 445,32767,32767, - 427,32767,32767, 220, 85,32767, 179,32767,32767,32767, - 32767,32767,32767,32767, 406,32767,32767, 181,32767,32767, - 426,32767,32767,32767,32767, 284,32767,32767,32767,32767, - 32767, 426,32767,32767,32767, 224,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 165,32767, 399, 399,32767, + 32767,32767,32767, 165, 394,32767, 165,32767,32767,32767, + 32767,32767, 165, 165, 178,32767, 176, 176,32767,32767, + 180,32767, 440, 180, 165, 198, 198, 376, 167, 233, + 32767, 233, 376, 165, 233,32767, 233,32767,32767,32767, + 83,32767,32767,32767,32767,32767,32767,32767,32767,32767, + 32767,32767,32767,32767,32767, 386,32767,32767, 406,32767, + 419, 438, 384,32767, 330, 331, 333,32767, 428, 355, + 356, 357, 358, 359, 360, 361, 363,32767, 468, 389, + 32767,32767,32767,32767,32767,32767, 85, 110, 247,32767, + 480, 85, 387,32767, 480,32767,32767,32767,32767,32767, + 32767, 289,32767,32767,32767, 85, 85,32767,32767, 464, + 32767, 482,32767, 426, 388,32767, 329, 402, 445,32767, + 32767, 427,32767,32767, 220, 85,32767, 179,32767,32767, + 32767,32767,32767,32767,32767, 406,32767,32767, 181,32767, + 32767, 426,32767,32767,32767,32767, 284,32767,32767,32767, + 32767,32767, 426,32767,32767,32767, 224,32767,32767,32767, 32767,32767,32767,32767,32767,32767,32767,32767,32767,32767, - 32767, 83, 60,32767, 265,32767,32767,32767,32767,32767, - 32767,32767,32767,32767,32767,32767,32767, 123, 123, 3, - 3, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 250, 156, 250, 206, - 250, 250, 209, 198, 198, 257 + 32767,32767, 83, 60,32767, 265,32767,32767,32767,32767, + 32767,32767,32767,32767,32767,32767,32767,32767, 123, 123, + 3, 3, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 250, 156, 250, + 206, 250, 250, 209, 198, 198, 257 ); protected $goto = array( - 163, 163, 135, 135, 135, 146, 148, 179, 164, 161, + 163, 163, 135, 135, 146, 135, 148, 179, 164, 161, 145, 161, 161, 161, 162, 162, 162, 162, 162, 162, - 162, 145, 157, 158, 159, 160, 176, 174, 177, 415, - 416, 301, 417, 420, 421, 422, 423, 424, 425, 426, - 427, 862, 136, 137, 138, 139, 140, 141, 142, 143, + 162, 145, 157, 158, 159, 160, 176, 174, 177, 414, + 415, 301, 416, 419, 420, 421, 422, 423, 424, 425, + 426, 863, 136, 137, 138, 139, 140, 141, 142, 143, 144, 147, 173, 175, 178, 195, 198, 199, 201, 202, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, - 233, 234, 251, 252, 253, 317, 318, 319, 465, 180, + 233, 234, 251, 252, 253, 316, 317, 318, 466, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 149, 194, 150, 165, 166, 167, 196, 168, 151, 152, 153, 169, 154, 197, 133, 170, 155, - 171, 172, 156, 523, 200, 654, 437, 533, 482, 499, - 467, 691, 653, 1043, 1043, 200, 442, 442, 442, 278, - 947, 770, 520, 750, 442, 559, 1043, 431, 779, 774, - 433, 436, 449, 468, 469, 471, 455, 457, 442, 562, - 489, 491, 511, 513, 767, 518, 519, 781, 526, 766, - 528, 534, 777, 536, 484, 484, 972, 972, 972, 972, - 972, 972, 972, 972, 972, 972, 972, 972, 419, 419, - 419, 419, 419, 419, 419, 419, 419, 419, 419, 419, - 419, 419, 678, 506, 5, 655, 514, 948, 300, 442, - 442, 685, 460, 456, 474, 442, 442, 949, 1003, 442, - 466, 832, 535, 460, 505, 515, 830, 487, 279, 946, - 336, 532, 443, 678, 678, 485, 486, 529, 463, 418, + 171, 172, 156, 524, 200, 655, 436, 534, 483, 500, + 468, 692, 654, 656, 278, 200, 441, 441, 441, 5, + 521, 771, 686, 751, 441, 560, 533, 430, 780, 775, + 432, 435, 448, 469, 470, 472, 454, 456, 441, 563, + 490, 492, 512, 514, 768, 519, 520, 782, 527, 767, + 529, 535, 778, 537, 485, 485, 973, 973, 973, 973, + 973, 973, 973, 973, 973, 973, 973, 973, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, 418, - 418, 418, 418, 296, 712, 1042, 1042, 754, 430, 448, - 458, 229, 461, 230, 231, 430, 1017, 1018, 1042, 257, - 245, 379, 464, 479, 804, 1035, 302, 1027, 500, 314, - 8, 909, 789, 1016, 1045, 671, 671, 800, 793, 679, - 679, 679, 681, 285, 330, 670, 674, 311, 808, 308, - 546, 672, 333, 940, 811, 682, 945, 374, 324, 501, - 329, 313, 313, 260, 261, 283, 462, 263, 323, 284, - 327, 490, 758, 481, 848, 280, 281, 385, 0, 0, + 418, 418, 679, 1018, 1019, 467, 833, 536, 441, 441, + 516, 831, 455, 475, 441, 441, 459, 429, 441, 713, + 948, 506, 1044, 1044, 429, 507, 947, 459, 515, 755, + 300, 442, 805, 679, 679, 1044, 302, 464, 417, 417, + 417, 417, 417, 417, 417, 417, 417, 417, 417, 417, + 417, 417, 296, 1043, 1043, 486, 487, 530, 447, 457, + 488, 279, 229, 335, 230, 231, 1043, 257, 245, 460, + 378, 465, 480, 1036, 1028, 501, 314, 910, 790, 8, + 1017, 801, 1046, 794, 672, 672, 949, 329, 680, 680, + 680, 682, 675, 308, 671, 285, 950, 1004, 311, 809, + 673, 547, 332, 941, 812, 683, 946, 373, 323, 502, + 328, 313, 313, 260, 261, 283, 463, 263, 322, 284, + 326, 491, 280, 281, 759, 482, 384, 849, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 951, 0, 0, 794, 794, 794, 794, 951, 1013, - 794, 794, 0, 1022, 1022, 0, 1013, 794, 0, 0, - 0, 0, 0, 1024, 1024, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1009, 748, 748, 748, 724, - 748, 0, 0, 743, 749, 725, 784, 784, 1032, 0, + 0, 952, 0, 0, 795, 795, 795, 795, 952, 1014, + 795, 795, 0, 1023, 1023, 0, 1014, 795, 0, 841, + 0, 0, 0, 1025, 1025, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1010, 749, 749, 749, 725, + 749, 0, 0, 744, 750, 726, 0, 0, 0, 0, + 785, 785, 1033, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 453, 811, 0, 1012, 1012, 811, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 454, 810, 0, 1011, 1011, 810, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 840, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 435, 453, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 435, 0, 453, - 0, 0, 0, 434, 0, 440, 365, 0, 367, 0, - 0, 0, 0, 0, 0, 0, 677, 1050 + 0, 0, 0, 0, 0, 434, 452, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 434, 0, 452, 0, + 0, 0, 433, 0, 439, 364, 0, 366, 0, 0, + 0, 0, 0, 0, 0, 678, 1052 ); protected $gotoCheck = array( @@ -634,76 +634,76 @@ class Php7 extends \PhpParser\ParserAbstract 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 54, 47, 13, 9, 8, 37, 37, - 82, 12, 12, 128, 128, 47, 9, 9, 9, 66, - 78, 12, 11, 12, 9, 12, 128, 12, 12, 12, + 82, 12, 12, 14, 66, 47, 9, 9, 9, 94, + 11, 12, 27, 12, 9, 12, 5, 12, 12, 12, 40, 40, 40, 40, 40, 40, 30, 9, 9, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, - 118, 118, 21, 58, 94, 14, 58, 78, 58, 9, - 9, 27, 71, 9, 9, 9, 9, 78, 78, 9, - 7, 7, 7, 71, 11, 7, 7, 64, 64, 11, - 64, 5, 9, 21, 21, 57, 57, 57, 9, 116, + 118, 118, 21, 122, 122, 7, 7, 7, 9, 9, + 7, 7, 9, 9, 9, 9, 71, 112, 9, 46, + 78, 11, 128, 128, 112, 58, 11, 71, 58, 31, + 58, 9, 80, 21, 21, 128, 43, 9, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, 116, - 116, 116, 116, 55, 46, 127, 127, 31, 112, 55, - 55, 62, 117, 62, 62, 112, 122, 122, 127, 115, - 115, 55, 2, 2, 80, 126, 43, 124, 45, 44, - 55, 99, 74, 120, 127, 21, 21, 76, 77, 21, - 21, 21, 21, 16, 20, 21, 23, 15, 81, 10, - 68, 22, 19, 105, 83, 24, 107, 60, 47, 47, + 116, 116, 55, 127, 127, 57, 57, 57, 55, 55, + 64, 64, 62, 64, 62, 62, 127, 115, 115, 117, + 55, 2, 2, 126, 124, 45, 44, 99, 74, 55, + 120, 76, 127, 77, 21, 21, 78, 20, 21, 21, + 21, 21, 23, 10, 21, 16, 78, 78, 15, 81, + 22, 68, 19, 105, 83, 24, 107, 60, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, - 47, 47, 65, 61, 96, 66, 66, 103, -1, -1, + 47, 47, 66, 66, 65, 61, 103, 96, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 54, -1, -1, 54, 54, 54, 54, 54, 82, - 54, 54, -1, 8, 8, -1, 82, 54, -1, -1, + 54, 54, -1, 8, 8, -1, 82, 54, -1, 94, -1, -1, -1, 82, 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 54, 54, 54, 54, - 54, -1, -1, 54, 54, 54, 71, 71, 71, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 54, -1, -1, 54, 54, 54, -1, -1, -1, -1, + 71, 71, 71, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 82, -1, 82, 82, 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 94, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, 8, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 8, -1, 8, - -1, -1, -1, 8, -1, 8, 8, -1, 8, -1, - -1, -1, -1, -1, -1, -1, 8, 8 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 8, 8, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 8, -1, 8, -1, + -1, -1, 8, -1, 8, 8, -1, 8, -1, -1, + -1, -1, -1, -1, -1, 8, 8 ); protected $gotoBase = array( - 0, 0, -277, 0, 0, 211, 0, 207, 107, -138, - 17, -167, 120, 113, 193, 2, 29, 0, 0, -46, - 19, -62, 5, 20, -55, -20, 0, 194, 0, 0, - -392, 231, 0, 0, 0, 0, 0, 87, 0, 0, - 105, 0, 0, 233, 51, 53, 230, 84, 0, 0, - 0, 0, 0, 0, 109, -114, 0, -11, -189, 0, - -71, -61, -307, 0, -51, -40, -248, 0, -8, 0, - 0, 172, -50, 0, 31, 0, 35, 30, -165, 0, - 243, -3, 117, -57, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 184, 0, -39, 0, 0, 32, - 0, 0, 0, -66, 0, -56, 0, -58, 0, 0, - 0, 0, 16, 0, 0, 4, 15, 229, -36, 0, - 26, 0, -33, 0, 226, 0, 241, 1, -121, 0, - 0 + 0, 0, -279, 0, 0, 126, 0, 192, 107, -138, + 11, -169, 120, 113, 121, 3, 31, 0, 0, -45, + 12, -62, 4, 16, -54, -20, 0, 125, 0, 0, + -393, 203, 0, 0, 0, 0, 0, 87, 0, 0, + 105, 0, 0, 193, 48, 50, 195, 84, 0, 0, + 0, 0, 0, 0, 109, -114, 0, 9, -166, 0, + -70, -58, -307, 0, -18, -37, -252, 0, -7, 0, + 0, 176, -50, 0, 27, 0, 29, 25, -85, 0, + 201, -2, 117, -56, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 119, 0, -35, 0, 0, 28, + 0, 0, 0, -66, 0, -55, 0, -57, 0, 0, + 0, 0, -25, 0, 0, 2, 14, 236, -36, 0, + 23, 0, -96, 0, 223, 0, 238, -1, -32, 0, + 0, 0 ); protected $gotoDefault = array( - -32768, 388, 567, 2, 568, 639, 647, 507, 405, 406, - 438, 439, 752, 692, 693, 304, 344, 407, 303, 331, - 325, 680, 673, 675, 683, 134, 334, 686, 1, 688, - 444, 720, 293, 696, 294, 510, 698, 451, 700, 701, - 432, 305, 306, 452, 312, 483, 711, 203, 309, 713, - 292, 714, 723, 299, 295, 386, 381, 472, 504, 361, - 371, 480, 228, 459, 476, 757, 277, 765, 551, 773, - 776, 408, 409, 473, 788, 375, 798, 792, 966, 320, - 803, 809, 998, 812, 815, 345, 332, 328, 819, 820, - 4, 824, 524, 525, 839, 240, 847, 495, 861, 349, - 928, 930, 446, 380, 941, 368, 335, 944, 1002, 362, - 410, 372, 958, 262, 282, 244, 411, 428, 249, 412, - 373, 1005, 1012, 315, 1028, 429, 1036, 1044, 273, 307, - 478 + -32768, 387, 568, 2, 569, 640, 648, 508, 404, 405, + 437, 438, 753, 693, 694, 304, 343, 406, 303, 330, + 324, 681, 674, 676, 684, 134, 333, 687, 1, 689, + 443, 721, 293, 697, 294, 511, 699, 450, 701, 702, + 431, 305, 306, 451, 312, 484, 712, 203, 309, 714, + 292, 715, 724, 299, 295, 385, 380, 473, 505, 360, + 370, 481, 228, 458, 477, 758, 277, 766, 552, 774, + 777, 407, 408, 474, 789, 374, 799, 793, 967, 319, + 804, 810, 999, 813, 816, 344, 331, 327, 820, 821, + 4, 825, 525, 526, 840, 240, 848, 496, 862, 348, + 929, 931, 445, 379, 942, 367, 334, 945, 1003, 361, + 409, 371, 959, 262, 282, 244, 410, 427, 249, 411, + 372, 1006, 1013, 315, 1029, 428, 1037, 1045, 273, 307, + 462, 479 ); protected $ruleToNonTerminal = array( @@ -755,8 +755,8 @@ class Php7 extends \PhpParser\ParserAbstract 113, 113, 113, 111, 111, 111, 120, 120, 120, 120, 71, 123, 123, 124, 124, 124, 124, 124, 117, 125, 125, 126, 126, 126, 126, 126, 115, 115, 115, 115, - 128, 129, 127, 127, 127, 127, 127, 127, 127, 130, - 130, 130, 130 + 128, 129, 130, 127, 127, 127, 127, 127, 127, 127, + 131, 131, 131, 131 ); protected $ruleToLength = array( @@ -808,8 +808,8 @@ class Php7 extends \PhpParser\ParserAbstract 3, 3, 3, 1, 3, 1, 1, 3, 1, 1, 4, 3, 1, 1, 1, 3, 3, 0, 1, 3, 1, 3, 1, 4, 2, 0, 2, 2, 1, 2, - 1, 1, 1, 4, 3, 3, 3, 6, 3, 1, - 1, 2, 1 + 1, 1, 1, 1, 4, 3, 3, 3, 6, 3, + 1, 1, 2, 1 ); protected function reduceRule0() { @@ -829,7 +829,7 @@ protected function reduceRule3() { } protected function reduceRule4() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; + $startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } @@ -1310,7 +1310,7 @@ protected function reduceRule123() { } protected function reduceRule124() { - $startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; + $startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $nop = null; }; if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } @@ -1435,7 +1435,7 @@ protected function reduceRule154() { } protected function reduceRule155() { - $startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; + $startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if ($this->useNopStatements && isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop(['comments' => $startAttributes['comments']]); } else { $this->semValue = null; }; if ($this->semValue === null) $this->semValue = array(); /* means: no statement */ } @@ -2757,19 +2757,19 @@ protected function reduceRule481() { } protected function reduceRule482() { - $this->semValue = $this->semStack[$this->stackPos-(1-1)]; + $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule483() { - $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); + $this->semValue = $this->semStack[$this->stackPos-(1-1)]; } protected function reduceRule484() { - $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(4-1)], $this->semStack[$this->stackPos-(4-3)], $this->startAttributeStack[$this->stackPos-(4-1)] + $this->endAttributes); } protected function reduceRule485() { - $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); + $this->semValue = new Expr\PropertyFetch($this->semStack[$this->stackPos-(3-1)], $this->semStack[$this->stackPos-(3-3)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); } protected function reduceRule486() { @@ -2777,26 +2777,30 @@ protected function reduceRule486() { } protected function reduceRule487() { - $this->semValue = new Expr\ArrayDimFetch(new Expr\Variable($this->semStack[$this->stackPos-(6-2)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes), $this->semStack[$this->stackPos-(6-4)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); + $this->semValue = new Expr\Variable($this->semStack[$this->stackPos-(3-2)], $this->startAttributeStack[$this->stackPos-(3-1)] + $this->endAttributes); } protected function reduceRule488() { - $this->semValue = $this->semStack[$this->stackPos-(3-2)]; + $this->semValue = new Expr\ArrayDimFetch($this->semStack[$this->stackPos-(6-2)], $this->semStack[$this->stackPos-(6-4)], $this->startAttributeStack[$this->stackPos-(6-1)] + $this->endAttributes); } protected function reduceRule489() { - $this->semValue = new Scalar\String_($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + $this->semValue = $this->semStack[$this->stackPos-(3-2)]; } protected function reduceRule490() { - $this->semValue = $this->parseNumString($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); + $this->semValue = new Scalar\String_($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule491() { - $this->semValue = $this->parseNumString('-' . $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); + $this->semValue = $this->parseNumString($this->semStack[$this->stackPos-(1-1)], $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } protected function reduceRule492() { + $this->semValue = $this->parseNumString('-' . $this->semStack[$this->stackPos-(2-2)], $this->startAttributeStack[$this->stackPos-(2-1)] + $this->endAttributes); + } + + protected function reduceRule493() { $this->semValue = new Expr\Variable(substr($this->semStack[$this->stackPos-(1-1)], 1), $this->startAttributeStack[$this->stackPos-(1-1)] + $this->endAttributes); } } diff --git a/lib/PhpParser/ParserAbstract.php b/lib/PhpParser/ParserAbstract.php index c1606f39fa..4eac35075b 100644 --- a/lib/PhpParser/ParserAbstract.php +++ b/lib/PhpParser/ParserAbstract.php @@ -6,6 +6,7 @@ * This parser is based on a skeleton written by Moriyoshi Koizumi, which in * turn is based on work by Masato Bito. */ +use PhpParser\Node\Expr; use PhpParser\Node\Name; use PhpParser\Node\Param; use PhpParser\Node\Scalar\LNumber; @@ -117,18 +118,21 @@ abstract class ParserAbstract implements Parser protected $useConsistentVariableNodes; /** @var bool Whether to use Stmt\Expr nodes */ protected $useExpressionStatements; + /** @var bool Whether to use Stmt\Nop nodes */ + protected $useNopStatements; /** * Creates a parser instance. * * Options: - * * useIdentifierNodes: If this option is enabled, the parser will create Identifier nodes for - * non-namespaced names. Otherwise plain strings will be used. - * * useConsistentVariableNodes: If this option is enabled, the parser will create Variable - * nodes in more places (like function parameters, catch clause variables, etc.) - * * useExpressionStatements: If this option is enabled, the parser will create Stmt\Expression - * nodes for statements of type "expr;". Otherwise the expression is directly included in the - * statement list. + * * useIdentifierNodes (default false): Create Identifier nodes for non-namespaced names. + * Otherwise plain strings will be used. + * * useConsistentVariableNodes (default false): Create Variable nodes in more places (like + * function parameters, catch clause variables, etc.) + * * useExpressionStatements (default false): Create Stmt\Expression nodes for statements of + * type "expr;". Otherwise the expression is directly included in the statement list + * * useNopStatements (default true): Create Stmt\Nop nodes for dangling comments at the end of + * statement lists. * * @param Lexer $lexer A lexer * @param array $options Options array. @@ -139,6 +143,8 @@ public function __construct(Lexer $lexer, array $options = array()) { $this->useIdentifierNodes = !empty($options['useIdentifierNodes']); $this->useConsistentVariableNodes = !empty($options['useConsistentVariableNodes']); $this->useExpressionStatements = !empty($options['useExpressionStatements']); + $this->useNopStatements = + isset($options['useNopStatements']) ? $options['useNopStatements'] : true; if (isset($options['throwOnError'])) { throw new \LogicException( @@ -471,8 +477,12 @@ protected function handleNamespaces(array $stmts) { // For semicolon namespaces we have to move the statements after a namespace declaration into ->stmts $resultStmts = array(); $targetStmts =& $resultStmts; + $lastNs = null; foreach ($stmts as $stmt) { if ($stmt instanceof Node\Stmt\Namespace_) { + if ($lastNs !== null) { + $this->fixupNamespaceAttributes($lastNs); + } if ($stmt->stmts === null) { $stmt->stmts = array(); $targetStmts =& $stmt->stmts; @@ -482,6 +492,7 @@ protected function handleNamespaces(array $stmts) { $resultStmts[] = $stmt; $targetStmts =& $resultStmts; } + $lastNs = $stmt; } elseif ($stmt instanceof Node\Stmt\HaltCompiler) { // __halt_compiler() is not moved into the namespace $resultStmts[] = $stmt; @@ -489,10 +500,31 @@ protected function handleNamespaces(array $stmts) { $targetStmts[] = $stmt; } } + if ($lastNs !== null) { + $this->fixupNamespaceAttributes($lastNs); + } return $resultStmts; } } + private function fixupNamespaceAttributes(Node\Stmt\Namespace_ $stmt) { + // We moved the statements into the namespace node, as such the end of the namespace node + // needs to be extended to the end of the statements. + if (empty($stmt->stmts)) { + return; + } + + // We only move the builtin end attributes here. This is the best we can do with the + // knowledge we have. + $endAttributes = ['endLine', 'endFilePos', 'endTokenPos']; + $lastStmt = $stmt->stmts[count($stmt->stmts) - 1]; + foreach ($endAttributes as $endAttribute) { + if ($lastStmt->hasAttribute($endAttribute)) { + $stmt->setAttribute($endAttribute, $lastStmt->getAttribute($endAttribute)); + } + } + } + private function getNamespacingStyle(array $stmts) { $style = null; $hasNotAllowedStmts = false; @@ -536,6 +568,56 @@ private function getNamespacingStyle(array $stmts) { return $style; } + protected function fixupPhp5StaticPropCall($prop, array $args, array $attributes) { + if ($prop instanceof Node\Expr\StaticPropertyFetch) { + // Preserve attributes if possible + $var = is_string($prop->name) + ? new Expr\Variable($prop->name) + : new Expr\Variable($prop->name, $prop->name->getAttributes()); + return new Expr\StaticCall($prop->class, $var, $args, $attributes); + } elseif ($prop instanceof Node\Expr\ArrayDimFetch) { + $tmp = $prop; + while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { + $tmp = $tmp->var; + } + + /** @var Expr\StaticPropertyFetch $staticProp */ + $staticProp = $tmp->var; + if (is_string($staticProp->name)) { + // Conservatively remove all attributes, as they may be incorrect + $tmp = $prop; + $tmp->setAttributes([]); + while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { + $tmp = $tmp->var; + $tmp->setAttributes([]); + } + } else { + // Set start attributes to attributes of innermost node + $tmp = $prop; + $this->fixupStartAttributes($tmp, $staticProp->name); + while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { + $tmp = $tmp->var; + $this->fixupStartAttributes($tmp, $staticProp->name); + } + } + + $result = new Expr\StaticCall($staticProp->class, $prop, $args, $attributes); + $tmp->var = new Expr\Variable($staticProp->name); + return $result; + } else { + throw new \Exception; + } + } + + protected function fixupStartAttributes(Node $to, Node $from) { + $startAttributes = ['startLine', 'startFilePos', 'startTokenPos']; + foreach ($startAttributes as $startAttribute) { + if ($from->hasAttribute($startAttribute)) { + $to->setAttribute($startAttribute, $from->getAttribute($startAttribute)); + } + } + } + protected function handleBuiltinTypes(Name $name) { $scalarTypes = [ 'bool' => true, diff --git a/lib/PhpParser/PrettyPrinter/Standard.php b/lib/PhpParser/PrettyPrinter/Standard.php index a6118ecd03..00c652ebaa 100644 --- a/lib/PhpParser/PrettyPrinter/Standard.php +++ b/lib/PhpParser/PrettyPrinter/Standard.php @@ -21,7 +21,7 @@ protected function pParam(Node\Param $node) { return ($node->type ? $this->pType($node->type) . ' ' : '') . ($node->byRef ? '&' : '') . ($node->variadic ? '...' : '') - . '$' . $node->name + . ($node->name instanceof Expr\Variable ? $this->p($node->name) : '$' . $node->name) . ($node->default ? ' = ' . $this->p($node->default) : ''); } @@ -37,6 +37,14 @@ protected function pNullableType(Node\NullableType $node) { return '?' . $this->pType($node->type); } + protected function pIdentifier(Node\Identifier $node) { + return $node->name; + } + + protected function pVarLikeIdentifier(Node\VarLikeIdentifier $node) { + return '$' . $node->name; + } + // Names protected function pName(Name $node) { @@ -543,7 +551,8 @@ protected function pExpr_Closure(Expr\Closure $node) { } protected function pExpr_ClosureUse(Expr\ClosureUse $node) { - return ($node->byRef ? '&' : '') . '$' . $node->var; + return ($node->byRef ? '&' : '') + . ($node->var instanceof Expr\Variable ? $this->p($node->var) : '$' . $node->var); } protected function pExpr_New(Expr\New_ $node) { @@ -754,8 +763,9 @@ protected function pStmt_TryCatch(Stmt\TryCatch $node) { } protected function pStmt_Catch(Stmt\Catch_ $node) { - return ' catch (' . $this->pImplode($node->types, '|') . ' $' . $node->var . ') {' - . $this->pStmts($node->stmts) . "\n" . '}'; + return ' catch (' . $this->pImplode($node->types, '|') . ' ' + . ($node->var instanceof Expr\Variable ? $this->p($node->var) : '$' . $node->var) + . ') {' . $this->pStmts($node->stmts) . "\n" . '}'; } protected function pStmt_Finally(Stmt\Finally_ $node) { @@ -788,6 +798,10 @@ protected function pStmt_Goto(Stmt\Goto_ $node) { // Other + protected function pStmt_Expression(Stmt\Expression $node) { + return $this->p($node->expr) . ';'; + } + protected function pStmt_Echo(Stmt\Echo_ $node) { return 'echo ' . $this->pCommaSeparated($node->exprs) . ';'; } @@ -801,7 +815,7 @@ protected function pStmt_Global(Stmt\Global_ $node) { } protected function pStmt_StaticVar(Stmt\StaticVar $node) { - return '$' . $node->name + return ($node->name instanceof Expr\Variable ? $this->p($node->name) : '$' . $node->name) . (null !== $node->default ? ' = ' . $this->p($node->default) : ''); } @@ -906,19 +920,7 @@ protected function encapsedContainsEndLabel(array $parts, $label) { } protected function pDereferenceLhs(Node $node) { - if ($node instanceof Expr\Variable - || $node instanceof Name - || $node instanceof Expr\ArrayDimFetch - || $node instanceof Expr\PropertyFetch - || $node instanceof Expr\StaticPropertyFetch - || $node instanceof Expr\FuncCall - || $node instanceof Expr\MethodCall - || $node instanceof Expr\StaticCall - || $node instanceof Expr\Array_ - || $node instanceof Scalar\String_ - || $node instanceof Expr\ConstFetch - || $node instanceof Expr\ClassConstFetch - ) { + if (!$this->dereferenceLhsRequiresParens($node)) { return $this->p($node); } else { return '(' . $this->p($node) . ')'; @@ -926,14 +928,7 @@ protected function pDereferenceLhs(Node $node) { } protected function pCallLhs(Node $node) { - if ($node instanceof Name - || $node instanceof Expr\Variable - || $node instanceof Expr\ArrayDimFetch - || $node instanceof Expr\FuncCall - || $node instanceof Expr\MethodCall - || $node instanceof Expr\StaticCall - || $node instanceof Expr\Array_ - ) { + if (!$this->callLhsRequiresParens($node)) { return $this->p($node); } else { return '(' . $this->p($node) . ')'; diff --git a/lib/PhpParser/PrettyPrinterAbstract.php b/lib/PhpParser/PrettyPrinterAbstract.php index ee7e17a368..4904485523 100644 --- a/lib/PhpParser/PrettyPrinterAbstract.php +++ b/lib/PhpParser/PrettyPrinterAbstract.php @@ -3,12 +3,22 @@ namespace PhpParser; use PhpParser\Node\Expr; +use PhpParser\Node\Scalar; use PhpParser\Node\Stmt; abstract class PrettyPrinterAbstract { + const FIXUP_PREC_LEFT = 0; // LHS operand affected by precedence + const FIXUP_PREC_RIGHT = 1; // RHS operand affected by precedence + const FIXUP_CALL_LHS = 2; // LHS of call + const FIXUP_DEREF_LHS = 3; // LHS of dereferencing operation + const FIXUP_BRACED_NAME = 4; // Name operand that may require bracing + const FIXUP_VAR_BRACED_NAME = 5; // Name operand that may require ${} bracing + const FIXUP_ENCAPSED = 6; // Encapsed string part + protected $precedenceMap = array( - // [precedence, associativity] where for the latter -1 is %left, 0 is %nonassoc and 1 is %right + // [precedence, associativity] + // where for precedence -1 is %left, 0 is %nonassoc and 1 is %right 'Expr_BinaryOp_Pow' => array( 0, 1), 'Expr_BitwiseNot' => array( 10, 1), 'Expr_PreInc' => array( 10, 1), @@ -74,11 +84,27 @@ abstract class PrettyPrinterAbstract 'Expr_Include' => array(200, -1), ); + /** @var string Token placed before newline to ensure it is not indented. */ protected $noIndentToken; + /** @var string Token placed at end of doc string to ensure it is followed by a newline. */ protected $docStringEndToken; + /** @var bool Whether semicolon namespaces can be used (i.e. no global namespace is used) */ protected $canUseSemicolonNamespaces; + /** @var array Pretty printer options */ protected $options; + /** @var array Original tokens for use in format-preserving pretty print */ + protected $origTokens; + /** @var int Current indentation level during format-preserving pretty pting */ + protected $indentLevel; + /** @var bool[] Map determining whether a certain character is a label character */ + protected $labelCharMap; + /** + * @var int[][] Map from token types and subnode names to FIXUP_* constants. This is used + * during format-preserving prints to place additional parens/braces if necessary. + */ + protected $fixupMap; + /** * Creates a pretty printer instance using the given options. * @@ -159,6 +185,12 @@ protected function preprocessNodes(array $nodes) { } } + /** + * Handles (and removes) no-indent and doc-string-end tokens. + * + * @param string $str + * @return string + */ protected function handleMagicTokens($str) { // Drop no-indent tokens $str = str_replace($this->noIndentToken, '', $str); @@ -199,17 +231,6 @@ protected function pStmts(array $nodes, $indent = true) { } } - /** - * Pretty prints a node. - * - * @param Node $node Node to be pretty printed - * - * @return string Pretty printed node - */ - protected function p(Node $node) { - return $this->{'p' . $node->getType()}($node); - } - protected function pInfixOp($type, Node $leftNode, $operatorString, Node $rightNode) { list($precedence, $associativity) = $this->precedenceMap[$type]; @@ -247,11 +268,11 @@ protected function pPrec(Node $node, $parentPrecedence, $parentAssociativity, $c if ($childPrecedence > $parentPrecedence || ($parentPrecedence == $childPrecedence && $parentAssociativity != $childPosition) ) { - return '(' . $this->{'p' . $type}($node) . ')'; + return '(' . $this->p($node) . ')'; } } - return $this->{'p' . $type}($node); + return $this->p($node); } /** @@ -313,4 +334,568 @@ protected function pComments(array $comments) { return implode("\n", $formattedComments); } + + /** + * Perform a format-preserving pretty print of an AST. + * + * The format preservation is best effort. For some changes to the AST the formatting will not + * be preserved (at least not locally). + * + * In order to use this method a number of prerequisites must be satisfied: + * * The startTokenPos and endTokenPos attributes in the lexer must be enabled. + * * The parser must be run with the options useIdentifierNodes, useConsistentVariableNodes, + * useExpressionStatements ENABLED and useNopStatements DISABLED. + * * The CloningVisitor must be run on the AST prior to modification. + * * The original tokens must be provided, using the getTokens() method on the lexer. + * + * @param Node[] $stmts Modified AST with links to original AST + * @param Node[] $origStmts Original AST with token offset information + * @param array $origTokens Tokens of the original code + * + * @return string + */ + public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens) { + $this->initializeLabelCharMap(); + $this->initializeFixupMap(); + + $this->origTokens = $origTokens; + $this->indentLevel = 0; + + $this->preprocessNodes($stmts); + + $pos = 0; + $result = $this->pArray($stmts, $origStmts, $pos, 0, null); + if (null !== $result) { + $result .= $this->getTokenCode($pos, count($this->origTokens), 0); + } else { + // Fallback + // TODO Add pStmts($stmts, false); + } + + return ltrim($this->handleMagicTokens($result)); + } + + protected function pFallback(Node $node) { + return $this->{'p' . $node->getType()}($node); + } + + /** + * Pretty prints a node. + * + * This method also handles formatting preservation for nodes. + * + * @param Node $node Node to be pretty printed + * + * @return string Pretty printed node + */ + protected function p(Node $node) { + // No orig tokens means this is a normal pretty print without preservation of formatting + if (!$this->origTokens) { + return $this->{'p' . $node->getType()}($node); + } + + /** @var Node $origNode */ + $origNode = $node->getAttribute('origNode'); + if (null === $origNode) { + return $this->pFallback($node); + } + + if (get_class($node) != get_class($origNode)) { + // Shouldn't happen + return $this->pFallback($node); + } + + $startPos = $origNode->getAttribute('startTokenPos', -1); + $endPos = $origNode->getAttribute('endTokenPos', -1); + if ($startPos < 0 || $endPos < 0) { + // Shouldn't happen + return $this->pFallback($node); + } + + if ($node instanceof Expr\New_ && $node->class instanceof Stmt\Class_) { + // For anonymous classes the new and class nodes are intermixed, this would require + // special handling (or maybe a new node type just for this?) + return $this->pFallback($node); + } + + $indentAdjustment = $this->indentLevel - $this->getIndentationBefore($startPos); + + $type = $node->getType(); + $fixupInfo = isset($this->fixupMap[$type]) ? $this->fixupMap[$type] : null; + + $result = ''; + $pos = $startPos; + foreach ($node->getSubNodeNames() as $i => $subNodeName) { + $subNode = $node->$subNodeName; + $origSubNode = $origNode->$subNodeName; + + if (!$subNode instanceof Node || !$origSubNode instanceof Node) { + if ($subNode === $origSubNode) { + // Unchanged, can reuse old code + continue; + } + + if (!is_array($subNode) || !is_array($origSubNode)) { + // If a non-node, non-array subnode changed, we don't be able to do a partial + // reconstructions, as we don't have enough offset information. Pretty print the + // whole node instead. + return $this->pFallback($node); + } + + $fixup = isset($fixupInfo[$subNodeName]) ? $fixupInfo[$subNodeName] : null; + $listResult = $this->pArray( + $subNode, $origSubNode, $pos, $indentAdjustment, $fixup + ); + if (null === $listResult) { + return $this->pFallback($node); + } + + $result .= $listResult; + continue; + } + + $subStartPos = $origSubNode->getAttribute('startTokenPos', -1); + $subEndPos = $origSubNode->getAttribute('endTokenPos', -1); + if ($subStartPos < 0 || $subEndPos < 0) { + // Shouldn't happen + return $this->pFallback($node); + } + + $result .= $this->getTokenCode($pos, $subStartPos, $indentAdjustment); + + $origIndentLevel = $this->indentLevel; + $this->indentLevel = $this->getIndentationBefore($subStartPos) + $indentAdjustment; + + // If it's the same node that was previously in this position, it certainly doesn't need + // fixup. It's important to check this here, because our fixup checks are more + // conservative than strictly necessary. + if (isset($fixupInfo[$subNodeName]) + && $subNode->getAttribute('origNode') !== $origSubNode + ) { + $fixup = $fixupInfo[$subNodeName]; + $res = $this->pFixup($fixup, $subNode, $type, $subStartPos, $subEndPos); + } else { + $res = $this->p($subNode); + } + + $this->safeAppend($result, $res); + $this->indentLevel = $origIndentLevel; + + $pos = $subEndPos + 1; + } + + $result .= $this->getTokenCode($pos, $endPos + 1, $indentAdjustment); + return $result; + } + + /** + * Perform a format-preserving pretty print of an array + * + * @param array $nodes New nodes + * @param array $origNodes Original nodes + * @param int $pos Current token position (updated by reference) + * @param int $indentAdjustment Adjustment for indentation + * @param null|int $fixup Fixup information for array item nodes + * + * @return null|string Result of pretty print or null if cannot preserve formatting + */ + protected function pArray(array $nodes, array $origNodes, &$pos, $indentAdjustment, $fixup) { + $len = count($nodes); + $origLen = count($origNodes); + if ($len !== $origLen) { + return null; + } + + $result = ''; + for ($i = 0; $i < $len; $i++) { + $arrItem = $nodes[$i]; + $origArrItem = $origNodes[$i]; + if ($arrItem === $origArrItem) { + // Unchanged, can reuse old code + continue; + } + + if (!$arrItem instanceof Node || !$origArrItem instanceof Node) { + // We can only handle arrays of nodes meaningfully + return null; + } + + $itemStartPos = $origArrItem->getAttribute('startTokenPos', -1); + $itemEndPos = $origArrItem->getAttribute('endTokenPos', -1); + if ($itemStartPos < 0 || $itemEndPos < 0) { + // Shouldn't happen + return null; + } + + $result .= $this->getTokenCode($pos, $itemStartPos, $indentAdjustment); + + $origIndentLevel = $this->indentLevel; + $this->indentLevel = $this->getIndentationBefore($itemStartPos) + $indentAdjustment; + + if (null !== $fixup && $arrItem->getAttribute('origNode') !== $origArrItem) { + $res = $this->pFixup($fixup, $arrItem, null, $itemStartPos, $itemEndPos); + } else { + $res = $this->p($arrItem); + } + $this->safeAppend($result, $res); + + $this->indentLevel = $origIndentLevel; + $pos = $itemEndPos + 1; + } + return $result; + } + + /** + * Print node with fixups. + * + * Fixups here refer to the addition of extra parentheses, braces or other characters, that + * are required to preserve program semantics in a certain context (e.g. to maintain precedence + * or because only certain expressions are allowed in certain places). + * + * @param int $fixup Fixup type + * @param Node $subNode Subnode to print + * @param string $parentType Type of parent node + * @param int $subStartPos Original start pos of subnode + * @param int $subEndPos Original end pos of subnode + * + * @return string Result of fixed-up print of subnode + */ + protected function pFixup($fixup, Node $subNode, $parentType, $subStartPos, $subEndPos) { + switch ($fixup) { + case self::FIXUP_PREC_LEFT: + case self::FIXUP_PREC_RIGHT: + if (!$this->haveParens($subStartPos, $subEndPos)) { + list($precedence, $associativity) = $this->precedenceMap[$parentType]; + return $this->pPrec($subNode, $precedence, $associativity, + $fixup === self::FIXUP_PREC_LEFT ? -1 : 1); + } + break; + case self::FIXUP_CALL_LHS: + if ($this->callLhsRequiresParens($subNode) + && !$this->haveParens($subStartPos, $subEndPos) + ) { + return '(' . $this->p($subNode) . ')'; + } + break; + case self::FIXUP_DEREF_LHS: + if ($this->dereferenceLhsRequiresParens($subNode) + && !$this->haveParens($subStartPos, $subEndPos) + ) { + return '(' . $this->p($subNode) . ')'; + } + break; + case self::FIXUP_BRACED_NAME: + case self::FIXUP_VAR_BRACED_NAME: + if ($subNode instanceof Expr + && !$this->haveBraces($subStartPos, $subEndPos) + ) { + return ($fixup === self::FIXUP_VAR_BRACED_NAME ? '$' : '') + . '{' . $this->p($subNode) . '}'; + } + break; + case self::FIXUP_ENCAPSED: + if (!$subNode instanceof Scalar\EncapsedStringPart + && !$this->haveBraces($subStartPos, $subEndPos) + ) { + return '{' . $this->p($subNode) . '}'; + } + break; + default: + throw new \Exception('Cannot happen'); + } + + // Nothing special to do + return $this->p($subNode); + } + + /** + * Appends to a string, ensuring whitespace between label characters. + * + * Example: "echo" and "$x" result in "echo$x", but "echo" and "x" result in "echo x". + * Without safeAppend the result would be "echox", which does not preserve semantics. + * + * @param string $str + * @param string $append + */ + protected function safeAppend(&$str, $append) { + // $append must not be empty in this function + if ($str === "") { + $str = $append; + return; + } + + if (!$this->labelCharMap[$append[0]] + || !$this->labelCharMap[$str[\strlen($str) - 1]]) { + $str .= $append; + } else { + $str .= " " . $append; + } + } + + /** + * Get indentation before token position + * + * @param int $pos Token position + * + * @return int Indentation depth (in spaces) + */ + protected function getIndentationBefore($pos) { + $tokens = $this->origTokens; + $indent = 0; + $pos--; + for (; $pos >= 0; $pos--) { + if ($tokens[$pos][0] !== T_WHITESPACE) { + $indent = 0; + continue; + } + $content = $tokens[$pos][1]; + $newlinePos = \strrpos($content, "\n"); + if (false !== $newlinePos) { + $indent += \strlen($content) - $newlinePos - 1; + return $indent; + } + + $indent += \strlen($content); + } + return $indent; + } + + protected function haveParens($startPos, $endPos) { + return $this->haveTokenImmediativelyBefore($startPos, '(') + && $this->haveTokenImmediatelyAfter($endPos, ')'); + } + + protected function haveBraces($startPos, $endPos) { + return $this->haveTokenImmediativelyBefore($startPos, '{') + && $this->haveTokenImmediatelyAfter($endPos, '}'); + } + + /** + * Check whether the position is directly preceded by a certain token type. + * + * During this check whitespace and comments are skipped. + * + * @param int $pos Position before which the token should occur + * @param int|string $expectedTokenType Token to check for + * + * @return bool Whether the expected token was found + */ + protected function haveTokenImmediativelyBefore($pos, $expectedTokenType) { + $tokens = $this->origTokens; + $pos--; + for (; $pos >= 0; $pos--) { + $tokenType = $tokens[$pos][0]; + if ($tokenType === $expectedTokenType) { + return true; + } + if ($tokenType !== T_WHITESPACE + && $tokenType !== T_COMMENT && $tokenType !== T_DOC_COMMENT) { + break; + } + } + return false; + } + + /** + * Check whether the position is directly followed by a certain token type. + * + * During this check whitespace and comments are skipped. + * + * @param int $pos Position after which the token should occur + * @param int|string $expectedTokenType Token to check for + * + * @return bool Whether the expected token was found + */ + protected function haveTokenImmediatelyAfter($pos, $expectedTokenType) { + $tokens = $this->origTokens; + $pos++; + for (; $pos < \count($tokens); $pos++) { + $tokenType = $tokens[$pos][0]; + if ($tokenType === $expectedTokenType) { + return true; + } + if ($tokenType !== T_WHITESPACE + && $tokenType !== T_COMMENT && $tokenType !== T_DOC_COMMENT) { + break; + } + } + return false; + } + + /** + * Get the code corresponding to a token offset range, optionally adjusted for indentation. + * + * @param int $from Token start position (inclusive) + * @param int $to Token end position (exclusive) + * @param int $indent By how much the code should be indented (can be negative as well) + * + * @return string Code corresponding to token range, adjusted for indentation + */ + protected function getTokenCode($from, $to, $indent) { + $tokens = $this->origTokens; + $result = ''; + for ($pos = $from; $pos < $to; $pos++) { + $token = $tokens[$pos]; + if (\is_array($token)) { + $type = $token[0]; + $content = $token[1]; + if ($type === T_CONSTANT_ENCAPSED_STRING || $type === T_ENCAPSED_AND_WHITESPACE) { + $result .= $this->pNoIndent($content); + } else { + // TODO Handle non-space indentation + if ($indent < 0) { + $result .= str_replace("\n" . str_repeat(" ", -$indent), "\n", $content); + } else if ($indent > 0) { + $result .= str_replace("\n", "\n" . str_repeat(" ", $indent), $content); + } else { + $result .= $content; + } + } + } else { + $result .= $token; + } + } + return $result; + } + + /** + * Determines whether the LHS of a call must be wrapped in parenthesis. + * + * @param Node $node LHS of a call + * + * @return bool Whether parentheses are required + */ + protected function callLhsRequiresParens(Node $node) { + return !($node instanceof Node\Name + || $node instanceof Expr\Variable + || $node instanceof Expr\ArrayDimFetch + || $node instanceof Expr\FuncCall + || $node instanceof Expr\MethodCall + || $node instanceof Expr\StaticCall + || $node instanceof Expr\Array_); + } + + /** + * Determines whether the LHS of a dereferencing operation must be wrapped in parenthesis. + * + * @param Node $node LHS of dereferencing operation + * + * @return bool Whether parentheses are required + */ + protected function dereferenceLhsRequiresParens(Node $node) { + return !($node instanceof Expr\Variable + || $node instanceof Node\Name + || $node instanceof Expr\ArrayDimFetch + || $node instanceof Expr\PropertyFetch + || $node instanceof Expr\StaticPropertyFetch + || $node instanceof Expr\FuncCall + || $node instanceof Expr\MethodCall + || $node instanceof Expr\StaticCall + || $node instanceof Expr\Array_ + || $node instanceof Scalar\String_ + || $node instanceof Expr\ConstFetch + || $node instanceof Expr\ClassConstFetch); + } + + /** + * Lazily initializes label char map. + * + * The label char map determines whether a certain character may occur in a label. + */ + protected function initializeLabelCharMap() { + if ($this->labelCharMap) return; + + $this->labelCharMap = []; + for ($i = 0; $i < 256; $i++) { + // Since PHP 7.1 The lower range is 0x80. However, we also want to support code for + // older versions. + $this->labelCharMap[chr($i)] = $i >= 0x7f || ctype_alnum($i); + } + } + + /** + * Lazily initializes fixup map. + * + * The fixup map is used to determine whether a certain subnode of a certain node may require + * some kind of "fixup" operation, e.g. the addition of parenthesis or braces. + */ + protected function initializeFixupMap() { + if ($this->fixupMap) return; + + $this->fixupMap = [ + 'Expr_PreInc' => ['var' => self::FIXUP_PREC_RIGHT], + 'Expr_PreDec' => ['var' => self::FIXUP_PREC_RIGHT], + 'Expr_PostInc' => ['var' => self::FIXUP_PREC_LEFT], + 'Expr_PostDec' => ['var' => self::FIXUP_PREC_LEFT], + 'Expr_Instanceof' => [ + 'expr' => self::FIXUP_PREC_LEFT, + 'class' => self::FIXUP_PREC_RIGHT, + ], + 'Expr_Ternary' => [ + 'cond' => self::FIXUP_PREC_LEFT, + 'else' => self::FIXUP_PREC_RIGHT, + ], + + 'Expr_FuncCall' => ['name' => self::FIXUP_CALL_LHS], + 'Expr_StaticCall' => ['class' => self::FIXUP_DEREF_LHS], + 'Expr_ArrayDimFetch' => ['var' => self::FIXUP_DEREF_LHS], + 'Expr_MethodCall' => [ + 'var' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_BRACED_NAME, + ], + 'Expr_StaticPropertyFetch' => [ + 'class' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_VAR_BRACED_NAME, + ], + 'Expr_PropertyFetch' => [ + 'var' => self::FIXUP_DEREF_LHS, + 'name' => self::FIXUP_BRACED_NAME, + ], + 'Scalar_Encapsed' => [ + 'parts' => self::FIXUP_ENCAPSED, + ], + ]; + + $binaryOps = [ + 'Expr_BinaryOp_Pow', 'Expr_BinaryOp_Mul', 'Expr_BinaryOp_Div', 'Expr_BinaryOp_Mod', + 'Expr_BinaryOp_Plus', 'Expr_BinaryOp_Minus', 'Expr_BinaryOp_Concat', + 'Expr_BinaryOp_ShiftLeft', 'Expr_BinaryOp_ShiftRight', 'Expr_BinaryOp_Smaller', + 'Expr_BinaryOp_SmallerOrEqual', 'Expr_BinaryOp_Greater', 'Expr_BinaryOp_GreaterOrEqual', + 'Expr_BinaryOp_Equal', 'Expr_BinaryOp_NotEqual', 'Expr_BinaryOp_Identical', + 'Expr_BinaryOp_NotIdentical', 'Expr_BinaryOp_Spaceship', 'Expr_BinaryOp_BitwiseAnd', + 'Expr_BinaryOp_BitwiseXor', 'Expr_BinaryOp_BitwiseOr', 'Expr_BinaryOp_BooleanAnd', + 'Expr_BinaryOp_BooleanOr', 'Expr_BinaryOp_Coalesce', 'Expr_BinaryOp_LogicalAnd', + 'Expr_BinaryOp_LogicalXor', 'Expr_BinaryOp_LogicalOr', + ]; + foreach ($binaryOps as $binaryOp) { + $this->fixupMap[$binaryOp] = [ + 'left' => self::FIXUP_PREC_LEFT, + 'right' => self::FIXUP_PREC_RIGHT + ]; + } + + $assignOps = [ + 'Expr_Assign', 'Expr_AssignRef', 'Expr_AssignOp_Plus', 'Expr_AssignOp_Minus', + 'Expr_AssignOp_Mul', 'Expr_AssignOp_Div', 'Expr_AssignOp_Concat', 'Expr_AssignOp_Mod', + 'Expr_AssignOp_BitwiseAnd', 'Expr_AssignOp_BitwiseOr', 'Expr_AssignOp_BitwiseXor', + 'Expr_AssignOp_ShiftLeft', 'Expr_AssignOp_ShiftRight', 'Expr_AssignOp_Pow', + ]; + foreach ($assignOps as $assignOp) { + $this->fixupMap[$assignOp] = [ + 'var' => self::FIXUP_PREC_LEFT, + 'expr' => self::FIXUP_PREC_RIGHT, + ]; + } + + $prefixOps = [ + 'Expr_BitwiseNot', 'Expr_BooleanNot', 'Expr_UnaryPlus', 'Expr_UnaryMinus', + 'Expr_Cast_Int', 'Expr_Cast_Double', 'Expr_Cast_String', 'Expr_Cast_Array', + 'Expr_Cast_Object', 'Expr_Cast_Bool', 'Expr_Cast_Unset', 'Expr_ErrorSuppress', + 'Expr_YieldFrom', 'Expr_Print', 'Expr_Include', + ]; + foreach ($prefixOps as $prefixOp) { + $this->fixupMap[$prefixOp] = ['expr' => self::FIXUP_PREC_RIGHT]; + } + } } diff --git a/test/PhpParser/CodeTestAbstract.php b/test/PhpParser/CodeTestAbstract.php index 369ee41b80..2169738383 100644 --- a/test/PhpParser/CodeTestAbstract.php +++ b/test/PhpParser/CodeTestAbstract.php @@ -4,7 +4,7 @@ abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase { - protected function getTests($directory, $fileExtension) { + protected function getTests($directory, $fileExtension, $chunksPerTest = 2) { $directory = realpath($directory); $it = new \RecursiveDirectoryIterator($directory); $it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::LEAVES_ONLY); @@ -33,11 +33,12 @@ function($matches) { $shortName = ltrim(str_replace($directory, '', $fileName), '/\\'); // multiple sections possible with always two forming a pair - $chunks = array_chunk($parts, 2); + $chunks = array_chunk($parts, $chunksPerTest); foreach ($chunks as $i => $chunk) { $dataSetName = $shortName . (count($chunks) > 1 ? '#' . $i : ''); - list($expected, $mode) = $this->extractMode($chunk[1]); - $tests[$dataSetName] = array($name, $chunk[0], $expected, $mode); + $lastPart = array_pop($chunk); + list($lastPart, $mode) = $this->extractMode($lastPart); + $tests[$dataSetName] = array_merge([$name], $chunk, [$lastPart, $mode]); } } diff --git a/test/PhpParser/PrettyPrinterTest.php b/test/PhpParser/PrettyPrinterTest.php index f1eae2411c..4f63048968 100644 --- a/test/PhpParser/PrettyPrinterTest.php +++ b/test/PhpParser/PrettyPrinterTest.php @@ -19,7 +19,13 @@ class PrettyPrinterTest extends CodeTestAbstract protected function doTestPrettyPrintMethod($method, $name, $code, $expected, $modeLine) { $lexer = new Lexer\Emulative; $parser5 = new Parser\Php5($lexer); - $parser7 = new Parser\Php7($lexer); + + // Use these options on one of the parsers ... don't want to write extra tests for them + $parser7 = new Parser\Php7($lexer, [ + 'useIdentifierNodes' => true, + 'useConsistentVariableNodes' => true, + 'useExpressionStatements' => true, + ]); list($version, $options) = $this->parseModeLine($modeLine); $prettyPrinter = new Standard($options); @@ -183,4 +189,113 @@ public function provideTestUnnaturalLiterals() { [new DNumber(-\NAN), '\NAN'], ]; } + + /** + * @dataProvider provideTestFormatPreservingPrint + * @covers \PhpParser\PrettyPrinter\Standard + */ + public function testFormatPreservingPrint($name, $code, $modification, $expected, $modeLine) { + $lexer = new Lexer\Emulative([ + 'usedAttributes' => [ + 'comments', + 'startLine', 'endLine', + 'startTokenPos', 'endTokenPos', + ], + ]); + + $parser = new Parser\Php7($lexer, [ + 'useIdentifierNodes' => true, + 'useConsistentVariableNodes' => true, + 'useExpressionStatements' => true, + 'useNopStatements' => false, + ]); + + $traverser = new NodeTraverser(); + $traverser->addVisitor(new NodeVisitor\CloningVisitor()); + + $printer = new PrettyPrinter\Standard(); + + $oldStmts = $parser->parse($code); + $oldTokens = $lexer->getTokens(); + + $newStmts = $traverser->traverse($oldStmts); + + /** @var callable $fn */ + eval(<<printFormatPreserving($newStmts, $oldStmts, $oldTokens); + $this->assertSame(canonicalize($expected), canonicalize($newCode), $name); + } + + public function provideTestFormatPreservingPrint() { + return $this->getTests(__DIR__ . '/../code/formatPreservation', 'test', 3); + } + + /** + * @dataProvider provideTestRoundTripPrint + * @covers \PhpParser\PrettyPrinter\Standard + */ + public function testRoundTripPrint($name, $code, $expected, $modeLine) { + /** + * This test makes sure that the format-preserving pretty printer round-trips for all + * the pretty printer tests (i.e. returns the input if no changes occurred). + */ + if (false !== strpos($code, 'new class')) { + // Can't preserve formatting on anon classes for now + return; + } + + list($version) = $this->parseModeLine($modeLine); + + $lexer = new Lexer\Emulative([ + 'usedAttributes' => [ + 'comments', + 'startLine', 'endLine', + 'startTokenPos', 'endTokenPos', + ], + ]); + + $parserClass = $version === 'php5' ? Parser\Php5::class : Parser\Php7::class; + /** @var Parser $parser */ + $parser = new $parserClass($lexer, [ + 'useIdentifierNodes' => true, + 'useConsistentVariableNodes' => true, + 'useExpressionStatements' => true, + 'useNopStatements' => false, + ]); + + $traverser = new NodeTraverser(); + $traverser->addVisitor(new NodeVisitor\CloningVisitor()); + + $printer = new PrettyPrinter\Standard(); + + try { + $oldStmts = $parser->parse($code); + } catch (Error $e) { + // Can't do a format-preserving print on a file with errors + return; + } + + $oldTokens = $lexer->getTokens(); + + $newStmts = $traverser->traverse($oldStmts); + + $newCode = $printer->printFormatPreserving($newStmts, $oldStmts, $oldTokens); + $this->assertSame(canonicalize($code), canonicalize($newCode), $name); + } + + public function provideTestRoundTripPrint() { + return array_merge( + $this->getTests(__DIR__ . '/../code/prettyPrinter', 'test'), + $this->getTests(__DIR__ . '/../code/parser', 'test') + ); + } } diff --git a/test/code/formatPreservation/abc1.test b/test/code/formatPreservation/abc1.test new file mode 100644 index 0000000000..ce8bd67903 --- /dev/null +++ b/test/code/formatPreservation/abc1.test @@ -0,0 +1,267 @@ +abc1 +----- +exprs[0]->left->right->value = 42; +----- +name = new Node\Identifier('bar'); +----- +byRef = true; +----- +byRef = true; +----- +stmts[0]; +$stmts[0]->stmts[0] = $stmts[1]; +$stmts[1] = $tmp; +----- +stmts[0]; +$stmts[0]->stmts[0] = $stmts[1]; +$stmts[1] = $tmp; +// Same test, but also appending to $stms, triggering fallback +$stmts[] = new Stmt\Echo_([new Scalar\LNumber(42)]); +----- +exprs[0] = new Expr\ConstFetch(new Node\Name('C')); +----- +expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')); +// The parens here are "correct", because add is left assoc +$stmts[1]->expr->right = new Expr\BinaryOp\Plus(new Expr\Variable('b'), new Expr\Variable('c')); +// No parens necessary +$stmts[2]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')); +// Parens for RHS not strictly necessary due to assign speciality +$stmts[3]->expr->cond = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')); +$stmts[3]->expr->if = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')); +$stmts[3]->expr->else = new Expr\Assign(new Expr\Variable('a'), new Expr\Variable('b')); +// Already has parens +$stmts[4]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')); +$stmts[5]->expr->left = new Expr\BinaryOp\Plus(new Expr\Variable('a'), new Expr\Variable('b')); +----- + bar; +$foo -> bar; +$foo -> bar; +$foo -> bar; +$foo -> bar; +self :: $foo; +self :: $foo; +----- +$stmts[0]->expr->name = new Expr\Variable('a'); +$stmts[1]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b')); +$stmts[2]->expr->var = new Expr\Variable('bar'); +$stmts[3]->expr->var = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b')); +$stmts[4]->expr->name = new Node\Identifier('foo'); +// In this case the braces are not strictly necessary. However, on PHP 5 they may be required +// depending on where the property fetch node itself occurs. +$stmts[5]->expr->name = new Expr\Variable('bar'); +$stmts[6]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b')); +$stmts[7]->expr->name = new Node\VarLikeIdentifier('bar'); +$stmts[8]->expr->name = new Expr\BinaryOp\Concat(new Expr\Variable('a'), new Expr\Variable('b')); +----- + bar; +($a . $b) -> bar; +$foo -> foo; +$foo -> {$bar}; +$foo -> {$a . $b}; +self :: $bar; +self :: ${$a . $b}; +----- +exprs[0]->parts[0] = new Expr\Variable('bar'); +$stmts[1]->exprs[0]->parts[0] = new Expr\Variable('bar'); +----- +