Commit Graph

350 Commits

Author SHA1 Message Date
Nikita Popov
d77e6cd6e9 Allow TraitUse statements in trait builder
Fixes #413.
2017-08-29 23:18:59 +02:00
Nikita Popov
a10780ca0d Handle Nop statement after brace-style namespace
Fixes #412.
2017-08-29 23:14:27 +02:00
Nikita Popov
4a7d011317 Add support for object type 2017-06-28 23:12:13 +02:00
Nikita Popov
7f862ac21c Add support for trailing comma in group use 2017-06-28 23:05:28 +02:00
Nikita Popov
bc0bff3f87 Fix method name in tests 2017-06-03 15:18:23 +02:00
Romain Neutron
c28b8556f5 Fix Lexer errorHandling when there is no tokens
I encounter an issue when no tokens exist. An error `Undefined offset -1` is triggered.
2017-06-03 15:17:45 +02:00
SignpostMarv
c877c1a64f Add Builder\Param::makeVariadic() 2017-04-19 11:16:29 +02:00
Nikita Popov
c3cbf07946 Pretty printer: Preserve comments in arrays and calls
If call arguments or array contains comments, print it in multiline
form, so that comments may be preserved.
2017-04-09 19:49:47 +02:00
Nikita Popov
d5873b177b Adjust the end attributes on the stack as well 2017-02-26 23:45:14 +01:00
Nikita Popov
48ec654d0c Make Expr\Error nodes empty
Resolves issue #359.
2017-02-26 23:38:32 +01:00
Nikita Popov
c12a4c8239 Fix start attribute assignment for Error in ClassConstFetch 2017-02-26 23:00:38 +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
62877b5d14 Recover from missing semicolons on statements 2017-02-05 17:47:56 +01:00
Nikita Popov
d287c167bc Pretty print: Handle Error in ClassConstFetch 2017-02-03 21:53:02 +01:00
Nikita Popov
58e7881e98 Implement NodeTraverser::STOP_TRAVERSAL
Conflicts:
	lib/PhpParser/NodeVisitor.php
2017-01-29 22:35:40 +01:00
Nikita Popov
fd7ac25108 Throw if pretty-printing Error node 2017-01-29 21:56:21 +01:00
Felix Becker
3e8c8d248d Add originalName attribute in NameResolver
For now gated behind a preserveOriginalNames option.
2016-12-22 20:25:02 +01:00
Nikita Popov
58970e2a37 Improve LNumber/DNumber pretty printing
* Support PHP_INT_MIN
* Support negative binary/octal/hex numbers
* Support INF/-INF/NAN in namespaces
2016-12-11 16:31:59 +01:00
Nikita Popov
c1e0bab4f8 Add support for negative interpolated offsets
A late addition to PHP 7.1 which I missed.
2016-12-11 13:44:17 +01:00
Nikita Popov
70319e27ee Parse 0 in "$a[0]" as LNumber (#325) 2016-12-07 20:24:00 +01:00
Nikita Popov
5219f75719 Fix pretty-printing of nullable types 2016-12-06 12:26:21 +01:00
Ondrej Mirtes
a485ecd7ba NameResolver - resolve Name in NullableType 2016-12-06 12:21:30 +01:00
Nikita Popov
3e158a2313 Wrap List_ in ArrayItem
This was correctly done for the 'key'=>list() form, but not for
unkeyed nested lists.
2016-12-01 13:32:37 +01:00
Nikita Popov
bcdfb703d5 Cleanup imports
Thanks PhpStorm :)
2016-11-23 22:58:18 +01:00
Nikita Popov
27281e9130 Fix attribute assignment for Error nodes 2016-11-23 22:51:32 +01:00
Nikita Popov
098294beec Support !!positions parser test mode
And use it for the group use prefix position test that was
previously implemented as a separate test.
2016-11-23 22:36:48 +01:00
Nikita Popov
b02f8ac07d Add support for dumping positions in NodeDumper 2016-11-23 22:25:17 +01:00
Nikita Popov
e52ffc4447 Support recovery from Foo:: 2016-11-22 19:47:04 +01:00
Nikita Popov
c5cdd5ad73 Support recovery from free-standing $ 2016-11-21 17:01:39 +01:00
Nikita Popov
c0630f8169 Support recovery for new without class name 2016-11-21 16:51:53 +01:00
Nikita Popov
fa7357b483 Represent empty Name::slice() using null
Instead of a Name([]) dummy value, that is invalid in other
contexts.
2016-10-22 17:02:38 +02:00
Nikita Popov
91cb82d3d2 Explicitly support Name copy construction
It already worked beforehand by accident ... make clear it's
actually supported.
2016-10-22 16:41:58 +02:00
Nikita Popov
7672b974ff Remove Name::append() and Name::prepend() 2016-10-22 00:25:15 +02:00
Nikita Popov
f99a96e0a2 Introduce ErrorHandler
Add ErrorHandler interface, as well as ErrorHandler\Throwing
and ErrorHandler\Collecting. The error handler is passed to
Parser::parse(). This supersedes the throwOnError option.

NameResolver now accepts an ErrorHandler in the ctor.
2016-10-16 22:12:46 +02:00
Nikita Popov
90834bff8e Add namespacedName attribute on runtime-resolved names
The NameResolver now adds a namespacedName attribute on function/
const names which cannot be statically resolved.
2016-10-11 19:44:22 +02:00
Nikita Popov
a910f6a247 Remove $separator arg from Name::toString() 2016-10-09 12:45:15 +02:00
Nikita Popov
caa5c0cc76 Graceful handling for "special" errors
Nearly all special errors are now handled gracefully, i.e. the
parser will be able to continue after encountering them. In some
cases the associated error range has been improved using the new
end attribute stack.

To achieve this the error handling code has been moved out of the
node constructors and into special methods in the parser.
2016-10-09 12:38:18 +02:00
Nikita Popov
5e5cb86e83 Remove support for node cloning in traverser 2016-10-09 00:41:55 +02:00
Nikita Popov
f6eb341b15 Fix GroupUse prefix attribute assignment 2016-10-08 23:55:46 +02:00
Nikita Popov
2e5ae28c39 Don't use deprecated getMock() 2016-09-30 20:42:19 +02:00
Nikita Popov
c79ea6d1d3 Support recovery from lexer errors
Lexer::startLexing() no longer throws, instead errors can be fetched
using Lexer::getErrors().

Lexer errors now also contain full line and position information.
2016-09-30 20:23:36 +02:00
Nikita Popov
9e5d3bbe25 Remove Error::(get|set)RawLine()
These have been superseded by Error::(get|set)StartLine().
2016-09-30 18:30:01 +02:00
Nikita Popov
f3c7dc9d89 Add Error::getMessageWithColumnInfo() 2016-09-30 18:24:43 +02:00
Nikita Popov
c5e0c3d7e2 Catch lexer errors in throwOnError=0 mode 2016-09-30 13:49:34 +02:00
Nikita Popov
ea47b6e0d6 Add NodeAbstract::setDocComment() 2016-09-17 20:51:22 +02:00
Nikita Popov
9e1c535b1d Update builder tests to use "flags" instead of "type" 2016-09-17 20:51:22 +02:00
Nikita Popov
1ab24d26ee Add support for PHP 7.1 types to builders
This adds support for void, iterable and nullable types.
2016-09-16 13:53:13 +02:00
Nikita Popov
a7120116b0 Merge branch '2.x' 2016-08-30 22:38:34 +02:00
Nikita Popov
83f34e7fa4 Retain comments on blocks on first inner statement 2016-08-30 22:37:51 +02:00