update 1.0.8.0
Commits for version update
This commit is contained in:
15
vendor/nikic/php-parser/CHANGELOG.md
vendored
15
vendor/nikic/php-parser/CHANGELOG.md
vendored
@@ -1,8 +1,21 @@
|
||||
Version 2.1.1-dev
|
||||
Version 2.1.2-dev
|
||||
-----------------
|
||||
|
||||
Nothing yet.
|
||||
|
||||
Version 2.1.1 (2016-09-16)
|
||||
--------------------------
|
||||
|
||||
### Changed
|
||||
|
||||
* The pretty printer will now escape all control characters in the range `\x00-\x1F` inside double
|
||||
quoted strings. If no special escape sequence is available, an octal escape will be used.
|
||||
* The quality of the error recovery has been improved. In particular unterminated expressions should
|
||||
be handled more gracefully.
|
||||
* The PHP 7 parser will now generate a parse error for `$var =& new Obj` assignments.
|
||||
* Comments on free-standing code blocks will no be retained as comments on the first statement in
|
||||
the code block.
|
||||
|
||||
Version 2.1.0 (2016-04-19)
|
||||
--------------------------
|
||||
|
||||
|
3
vendor/nikic/php-parser/grammar/php5.y
vendored
3
vendor/nikic/php-parser/grammar/php5.y
vendored
@@ -150,7 +150,7 @@ inner_statement:
|
||||
;
|
||||
|
||||
non_empty_statement:
|
||||
'{' inner_statement_list '}' { $$ = $2; }
|
||||
'{' inner_statement_list '}' { $$ = $2; prependLeadingComments($$); }
|
||||
| T_IF parentheses_expr statement elseif_list else_single
|
||||
{ $$ = Stmt\If_[$2, ['stmts' => toArray($3), 'elseifs' => $4, 'else' => $5]]; }
|
||||
| T_IF parentheses_expr ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';'
|
||||
@@ -183,6 +183,7 @@ non_empty_statement:
|
||||
| T_THROW expr ';' { $$ = Stmt\Throw_[$2]; }
|
||||
| T_GOTO T_STRING ';' { $$ = Stmt\Goto_[$2]; }
|
||||
| T_STRING ':' { $$ = Stmt\Label[$1]; }
|
||||
| expr error { $$ = $1; }
|
||||
| error { $$ = array(); /* means: no statement */ }
|
||||
;
|
||||
|
||||
|
4
vendor/nikic/php-parser/grammar/php7.y
vendored
4
vendor/nikic/php-parser/grammar/php7.y
vendored
@@ -150,7 +150,7 @@ inner_statement:
|
||||
;
|
||||
|
||||
non_empty_statement:
|
||||
'{' inner_statement_list '}' { $$ = $2; }
|
||||
'{' inner_statement_list '}' { $$ = $2; prependLeadingComments($$); }
|
||||
| T_IF '(' expr ')' statement elseif_list else_single
|
||||
{ $$ = Stmt\If_[$3, ['stmts' => toArray($5), 'elseifs' => $6, 'else' => $7]]; }
|
||||
| T_IF '(' expr ')' ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';'
|
||||
@@ -179,6 +179,7 @@ non_empty_statement:
|
||||
| T_THROW expr ';' { $$ = Stmt\Throw_[$2]; }
|
||||
| T_GOTO T_STRING ';' { $$ = Stmt\Goto_[$2]; }
|
||||
| T_STRING ':' { $$ = Stmt\Label[$1]; }
|
||||
| expr error { $$ = $1; }
|
||||
| error { $$ = array(); /* means: no statement */ }
|
||||
;
|
||||
|
||||
@@ -511,7 +512,6 @@ expr:
|
||||
| list_expr '=' expr { $$ = Expr\Assign[$1, $3]; }
|
||||
| variable '=' expr { $$ = Expr\Assign[$1, $3]; }
|
||||
| variable '=' '&' variable { $$ = Expr\AssignRef[$1, $4]; }
|
||||
| variable '=' '&' new_expr { $$ = Expr\AssignRef[$1, $4]; }
|
||||
| new_expr { $$ = $1; }
|
||||
| T_CLONE expr { $$ = Expr\Clone_[$2]; }
|
||||
| variable T_PLUS_EQUAL expr { $$ = Expr\AssignOp\Plus [$1, $3]; }
|
||||
|
@@ -195,6 +195,15 @@ function resolveMacros($code) {
|
||||
. $args[0] . '[\'docLabel\'] = $matches[1];';
|
||||
}
|
||||
|
||||
if ('prependLeadingComments' == $name) {
|
||||
assertArgs(1, $args, $name);
|
||||
|
||||
return '$attrs = $this->startAttributeStack[#1]; $stmts = ' . $args[0] . '; '
|
||||
. 'if (!empty($attrs[\'comments\']) && isset($stmts[0])) {'
|
||||
. '$stmts[0]->setAttribute(\'comments\', '
|
||||
. 'array_merge($attrs[\'comments\'], $stmts[0]->getAttribute(\'comments\', []))); }';
|
||||
}
|
||||
|
||||
return $matches[0];
|
||||
},
|
||||
$code
|
||||
|
2396
vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php
vendored
2396
vendor/nikic/php-parser/lib/PhpParser/Parser/Php5.php
vendored
File diff suppressed because it is too large
Load Diff
1276
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
1276
vendor/nikic/php-parser/lib/PhpParser/Parser/Php7.php
vendored
File diff suppressed because it is too large
Load Diff
@@ -351,7 +351,9 @@ abstract class ParserAbstract implements Parser
|
||||
&& ($idx = $this->actionBase[$state + $this->YYNLSTATES] + $symbol) >= 0
|
||||
&& $idx < $this->actionTableSize && $this->actionCheck[$idx] === $symbol
|
||||
) {
|
||||
if ($this->action[$idx] != $this->unexpectedTokenRule) {
|
||||
if ($this->action[$idx] != $this->unexpectedTokenRule
|
||||
&& $this->action[$idx] != $this->defaultAction
|
||||
) {
|
||||
if (count($expected) == 4) {
|
||||
/* Too many expected tokens */
|
||||
return array();
|
||||
|
@@ -849,9 +849,20 @@ class Standard extends PrettyPrinterAbstract
|
||||
protected function escapeString($string, $quote) {
|
||||
if (null === $quote) {
|
||||
// For doc strings, don't escape newlines
|
||||
return addcslashes($string, "\t\f\v$\\");
|
||||
$escaped = addcslashes($string, "\t\f\v$\\");
|
||||
} else {
|
||||
$escaped = addcslashes($string, "\n\r\t\f\v$" . $quote . "\\");
|
||||
}
|
||||
return addcslashes($string, "\n\r\t\f\v$" . $quote . "\\");
|
||||
|
||||
// Escape other control characters
|
||||
return preg_replace_callback('/([\0-\10\16-\37])(?=([0-7]?))/', function ($matches) {
|
||||
$oct = decoct(ord($matches[1]));
|
||||
if ($matches[2] !== '') {
|
||||
// If there is a trailing digit, use the full three character form
|
||||
return '\\' . str_pad($oct, 3, '0', STR_PAD_LEFT);
|
||||
}
|
||||
return '\\' . $oct;
|
||||
}, $escaped);
|
||||
}
|
||||
|
||||
protected function containsEndLabel($string, $label, $atStart = true, $atEnd = true) {
|
||||
|
@@ -5,13 +5,14 @@ namespace PhpParser;
|
||||
abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function getTests($directory, $fileExtension) {
|
||||
$directory = realpath($directory);
|
||||
$it = new \RecursiveDirectoryIterator($directory);
|
||||
$it = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::LEAVES_ONLY);
|
||||
$it = new \RegexIterator($it, '(\.' . preg_quote($fileExtension) . '$)');
|
||||
|
||||
$tests = array();
|
||||
foreach ($it as $file) {
|
||||
$fileName = realpath($file->getPathname());
|
||||
$fileName = $file->getPathname();
|
||||
$fileContents = file_get_contents($fileName);
|
||||
$fileContents = canonicalize($fileContents);
|
||||
|
||||
@@ -29,7 +30,7 @@ abstract class CodeTestAbstract extends \PHPUnit_Framework_TestCase
|
||||
|
||||
// first part is the name
|
||||
$name = array_shift($parts) . ' (' . $fileName . ')';
|
||||
$shortName = basename($fileName, '.test');
|
||||
$shortName = ltrim(str_replace($directory, '', $fileName), '/\\');
|
||||
|
||||
// multiple sections possible with always two forming a pair
|
||||
$chunks = array_chunk($parts, 2);
|
||||
|
23
vendor/nikic/php-parser/test/code/parser/blockComments.test
vendored
Normal file
23
vendor/nikic/php-parser/test/code/parser/blockComments.test
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Comments on blocks
|
||||
-----
|
||||
<?php
|
||||
|
||||
// foo
|
||||
{
|
||||
// bar
|
||||
{
|
||||
// baz
|
||||
$a;
|
||||
}
|
||||
}
|
||||
-----
|
||||
array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
comments: array(
|
||||
0: // foo
|
||||
1: // bar
|
||||
2: // baz
|
||||
)
|
||||
)
|
||||
)
|
@@ -4,15 +4,29 @@ Error positions
|
||||
-----
|
||||
Syntax error, unexpected EOF from 1:10 to 1:10
|
||||
array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php foo /* bar */
|
||||
-----
|
||||
Syntax error, unexpected EOF from 1:20 to 1:20
|
||||
array(
|
||||
0: Stmt_Nop(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Nop(
|
||||
comments: array(
|
||||
0: /* bar */
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
@@ -10,6 +10,33 @@ Syntax error, unexpected T_STRING from 4:1 to 4:3
|
||||
Syntax error, unexpected T_STRING from 5:1 to 5:3
|
||||
Syntax error, unexpected EOF from 5:6 to 5:6
|
||||
array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: baz
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
@@ -23,13 +50,22 @@ array(
|
||||
0: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
0: foo
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: baz
|
||||
@@ -58,6 +94,15 @@ array(
|
||||
)
|
||||
)
|
||||
1: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: bar
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
2: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: baz
|
||||
@@ -81,6 +126,9 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
@@ -97,6 +145,9 @@ array(
|
||||
)
|
||||
returnType: null
|
||||
stmts: array(
|
||||
0: Scalar_LNumber(
|
||||
value: 1
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@@ -23,7 +23,6 @@ $a = $b *= $c **= $d;
|
||||
|
||||
// by ref assign
|
||||
$a =& $b;
|
||||
$a =& new B;
|
||||
|
||||
// list() assign
|
||||
list($a) = $b;
|
||||
@@ -191,21 +190,7 @@ array(
|
||||
0: // by ref assign
|
||||
)
|
||||
)
|
||||
15: Expr_AssignRef(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
16: Expr_Assign(
|
||||
15: Expr_Assign(
|
||||
var: Expr_List(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
@@ -223,7 +208,7 @@ array(
|
||||
0: // list() assign
|
||||
)
|
||||
)
|
||||
17: Expr_Assign(
|
||||
16: Expr_Assign(
|
||||
var: Expr_List(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
@@ -239,7 +224,7 @@ array(
|
||||
name: c
|
||||
)
|
||||
)
|
||||
18: Expr_Assign(
|
||||
17: Expr_Assign(
|
||||
var: Expr_List(
|
||||
vars: array(
|
||||
0: Expr_Variable(
|
||||
@@ -262,7 +247,7 @@ array(
|
||||
name: e
|
||||
)
|
||||
)
|
||||
19: Expr_PreInc(
|
||||
18: Expr_PreInc(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
@@ -270,17 +255,17 @@ array(
|
||||
0: // inc/dec
|
||||
)
|
||||
)
|
||||
20: Expr_PostInc(
|
||||
19: Expr_PostInc(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
21: Expr_PreDec(
|
||||
20: Expr_PreDec(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
)
|
||||
22: Expr_PostDec(
|
||||
21: Expr_PostDec(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
|
39
vendor/nikic/php-parser/test/code/parser/expr/assignNewByRef.test
vendored
Normal file
39
vendor/nikic/php-parser/test/code/parser/expr/assignNewByRef.test
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
Assigning new by reference (PHP 5 only)
|
||||
-----
|
||||
<?php
|
||||
$a =& new B;
|
||||
-----
|
||||
!!php5
|
||||
array(
|
||||
0: Expr_AssignRef(
|
||||
var: Expr_Variable(
|
||||
name: a
|
||||
)
|
||||
expr: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
$a =& new B;
|
||||
-----
|
||||
!!php7
|
||||
Syntax error, unexpected T_NEW from 2:7 to 2:9
|
||||
array(
|
||||
0: Expr_New(
|
||||
class: Name(
|
||||
parts: array(
|
||||
0: B
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
@@ -50,6 +50,9 @@ array(
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
comments: array(
|
||||
0: // class name variations
|
||||
)
|
||||
)
|
||||
3: Expr_New(
|
||||
class: Expr_ArrayDimFetch(
|
||||
@@ -84,6 +87,9 @@ array(
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
comments: array(
|
||||
0: // DNCR object access
|
||||
)
|
||||
)
|
||||
6: Expr_New(
|
||||
class: Expr_PropertyFetch(
|
||||
|
@@ -34,6 +34,20 @@ use Foo {Bar, Baz};
|
||||
-----
|
||||
Syntax error, unexpected '{', expecting ',' or ';' from 3:9 to 3:9
|
||||
array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: Bar
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Expr_ConstFetch(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: Baz
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php
|
||||
@@ -42,4 +56,11 @@ use Foo\{\Bar};
|
||||
-----
|
||||
Syntax error, unexpected T_NS_SEPARATOR, expecting T_STRING or T_FUNCTION or T_CONST from 3:10 to 3:10
|
||||
array(
|
||||
0: Expr_ConstFetch(
|
||||
name: Name_FullyQualified(
|
||||
parts: array(
|
||||
0: Bar
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
23
vendor/nikic/php-parser/test/code/prettyPrinter/expr/stringEscaping.test
vendored
Normal file
23
vendor/nikic/php-parser/test/code/prettyPrinter/expr/stringEscaping.test
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
Escape sequences in double-quoted strings
|
||||
-----
|
||||
<?php
|
||||
"\n\r\t\f\v\$\"\\";
|
||||
"@@{ implode(range("\0", "\37")) }@@";
|
||||
"\0000\0001";
|
||||
|
||||
<<<DOC
|
||||
\n\r\t\f\v\$\"\\
|
||||
@@{ implode(range("\0", "\37")) }@@
|
||||
\0000\0001
|
||||
DOC;
|
||||
|
||||
-----
|
||||
"\n\r\t\f\v\$\"\\";
|
||||
"\0\1\2\3\4\5\6\7\10\t\n\v\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37";
|
||||
"\0000\0001";
|
||||
<<<DOC
|
||||
@@{ "\n\r" }@@\t\f\v\$\\"\\
|
||||
\0\1\2\3\4\5\6\7\10\t@@{ "\n" }@@\v\f@@{ "\r" }@@\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37
|
||||
\0000\0001
|
||||
DOC
|
||||
;
|
Reference in New Issue
Block a user