Commit Graph

318 Commits

Author SHA1 Message Date
Matthew Brown
329e90c239 Improve doc comments 2017-02-09 20:49:52 +01:00
Nikita Popov
9f5ec5a69a Merge branch '3.x'
Conflicts:
	lib/PhpParser/Parser/Php5.php
	lib/PhpParser/Parser/Php7.php
	test/code/parser/stmt/class/name.test
2017-02-09 20:38:33 +01:00
Nikita Popov
df98b0417b Handle "extends static" etc more gracefully
Use class_name production and emit the same error as for
"extends self" and "extends parent". It's weird that "extends
static" gives a different result than those two.
2017-02-09 18:43:09 +01:00
Nikita Popov
a8eb2fc675 Support recovery from invalid trailing commas 2017-02-09 00:35:12 +01:00
Nikita Popov
d18ccfeec7 Use p() in pPrec() for easier extensibility 2017-02-09 00:03:00 +01:00
Nikita Popov
f8a2f6e760 Merge branch '3.x' 2017-02-08 23:55:16 +01:00
Jennifer Hodgdon
4e55897059 Change one function to protected 2017-02-08 23:55:02 +01:00
Nikita Popov
865bfb2acf Merge branch '3.x'
Conflicts:
	grammar/php7.y
	lib/PhpParser/Parser/Php7.php
	test/code/parser/expr/uvs/globalNonSimpleVarError.test
	test/code/parser/stmt/namespace/groupUseErrors.test
2017-02-05 17:50:54 +01:00
Nikita Popov
62877b5d14 Recover from missing semicolons on statements 2017-02-05 17:47:56 +01:00
Nikita Popov
8f623fb241 Use closures instead of methods for semantic actions
The dispatch using $this->{'reduceRule' . $rule}() is very expensive
because it involves
 * One allocation when converting $rule to a string
 * Another allocation when concatenating the two strings
 * Lowercasing during the method call
 * Various uncached method checks, e.g. visibility.

Using an array of closures for semantic action dispatch is
significantly more efficient.
2017-02-05 11:58:45 +01:00
Nikita Popov
3bbf8d8f7a Use local var for $stackPos
We're accessing $this->stackPos a lot, and property accesses are
much more expensive than local variable acesses. Its cheaper to
use a local var and pass it as an argument to semantic actions.
2017-02-05 11:57:21 +01:00
Nikita Popov
90b6d7cb5b Remove XML serializer 2017-02-04 01:10:09 +01:00
Nikita Popov
7fa5495d64 Merge branch '3.x' 2017-02-03 22:59:06 +01:00
Nikita Popov
42f046ec19 Deprecate XML serializer 2017-02-03 22:52:16 +01:00
Nikita Popov
987c61e935 Drop support for false return value in NodeTraverser 2017-02-03 22:36:57 +01:00
Nikita Popov
2b72bae3d9 Throw if NodeVisitor returns invalid value 2017-02-03 22:30:26 +01:00
Nikita Popov
2b6804aa50 Throw on nested array in NodeTraverser
The AST never uses deeply nested arrays, so don't support this in
the node traverser. Throw an exception instead.
2017-02-03 22:11:31 +01:00
Nikita Popov
d9911c8da5 Merge branch '3.x'
Conflicts:
	lib/PhpParser/Node/Expr/ClassConstFetch.php
	test/PhpParser/PrettyPrinterTest.php
2017-02-03 21:54:48 +01:00
Nikita Popov
d287c167bc Pretty print: Handle Error in ClassConstFetch 2017-02-03 21:53:02 +01:00
Nikita Popov
79afd56565 Add NodeFinder class
To simplify basic node finding operations.
2017-01-29 23:20:53 +01:00
Nikita Popov
5cc2750ebc Merge branch '3.x'
Conflicts:
	lib/PhpParser/NodeVisitor.php
2017-01-29 22:36:33 +01:00
Nikita Popov
58e7881e98 Implement NodeTraverser::STOP_TRAVERSAL
Conflicts:
	lib/PhpParser/NodeVisitor.php
2017-01-29 22:35:40 +01:00
Nikita Popov
e072c789d1 Merge branch '3.x'
Conflicts:
	test/PhpParser/PrettyPrinterTest.php
2017-01-29 21:57:37 +01:00
Nikita Popov
fd7ac25108 Throw if pretty-printing Error node 2017-01-29 21:56:21 +01:00
Nikita Popov
bfea338d36 Update doc comments after previous comment
Make some of the type annotations more accurate, and complete the
generated doc-comments to be complete (with description and
parameter annotations.)
2017-01-26 00:16:54 +01:00
Matthew Brown
e3b87f40aa Add non-void return types 2017-01-25 23:32:50 +01:00
Nikita Popov
70f86cb6cb Update NodeVisitor doc comments 2017-01-25 23:28:44 +01:00
Nikita Popov
13304d5991 Drop attribute poisoning in parser 2017-01-23 01:13:34 +01:00
Matthew Brown
7b441d2142 Fix issues reported by psalm 2017-01-23 01:06:46 +01:00
Nikita Popov
cb5dd28985 Don't include whitespace directly in catch/finally print 2017-01-21 21:25:48 +01:00
Nikita Popov
5e565e8046 Support insertion of nullable nodes
Still incomplete in some places and the formatting is not always
ideal.
2017-01-21 21:20:42 +01:00
Nikita Popov
b9b6aeeed9 Support format-preserving node removal
Take care of stripping surrouding tokens appropriately.
2017-01-21 17:52:50 +01:00
Nikita Popov
0607450f78 Add FinderVisitor
Allows finding nodes based on a filter callback.
2017-01-21 15:41:24 +01:00
Nikita Popov
aea3a9efe4 Add @property annotations for namespacedName 2017-01-20 23:45:54 +01:00
Nikita Popov
414adfb146 Drop useNopStatements option 2017-01-20 22:29:41 +01:00
Nikita Popov
b5fb6f2d0a Don't require useNopStatements=false for format preservation
Instead assign attributes on Nop nodes and in the pretty printer
specially handle end<start offsets. It's a somewhat weird case,
but not wrong per se given the meaning the offsets have.
2017-01-20 22:27:51 +01:00
Nikita Popov
48d3243abe Drop last vestiges of consistent var mode flag 2017-01-19 23:46:25 +01:00
Nikita Popov
d7f3c4f9d3 Renamve Param::$name to Param::$var
As it now contains a Variable node.
2017-01-19 23:39:15 +01:00
Nikita Popov
a79306ccd9 Rename StaticVar::$name to $var
As it now holds a Variable
2017-01-19 23:35:31 +01:00
Nikita Popov
6238f5f9f9 Adjust code for constitent var mode 2017-01-19 23:32:49 +01:00
Nikita Popov
67274b9594 Enforce useConsistentVariableNames 2017-01-19 23:24:43 +01:00
Nikita Popov
ced914a3b7 Update doc comments to be more specific
Now $stmts arrays really only contains Stmt nodes.
2017-01-19 22:49:18 +01:00
Nikita Popov
7623d20f69 Automatically wrap in Stmt\Expression in builders 2017-01-19 22:39:21 +01:00
Nikita Popov
1bfbd7bcc8 Make useExpressionStatement only supported mode 2017-01-19 21:15:26 +01:00
Nikita Popov
065c720c28 Merge branch 'formatPreservingPrint' 2017-01-19 21:06:32 +01:00
Nikita Popov
0c9c8d58ab Drop deprecated $type subnodes
These have been replaced by $flags in 3.0
2017-01-19 21:00:44 +01:00
Nikita Popov
3b4dd387b8 Comment out code for handling new keywords 2017-01-19 20:58:45 +01:00
Nikita Popov
61574a1818 Drop support for PHP 5.5 2017-01-19 20:55:08 +01:00
algo13
ba57202ed7 Fixed method name casing (#336)
Make it match the parent class.
2017-01-14 12:01:25 +01:00
Nikita Popov
f21309f52f Add NameResolver mode that does not modify nodes 2016-12-26 21:45:33 +01:00