Commit Graph

274 Commits

Author SHA1 Message Date
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
86ea6fe8c4 Remove leftover code 2017-02-26 22:53:08 +01:00
Nikita Popov
1b59e918f7 Perform NullableType resolution earlier
This makes sure function signatures are already fully resolved in
enterNode(). Resolves issue #360.
2017-02-26 22:50:31 +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
Jennifer Hodgdon
4e55897059 Change one function to protected 2017-02-08 23:55:02 +01:00
Nikita Popov
62877b5d14 Recover from missing semicolons on statements 2017-02-05 17:47:56 +01:00
Nikita Popov
42f046ec19 Deprecate XML serializer 2017-02-03 22:52:16 +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
algo13
ba57202ed7 Fixed method name casing (#336)
Make it match the parent class.
2017-01-14 12:01:25 +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
Matthew Brown
030de805e1 Add NullableType to types of properties/args that offer it (#323) 2016-12-05 13:30:29 +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
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
c0f0edf044 Mark Name::$parts as deprecated 2016-10-22 17:05:00 +02: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
0d0accfa9f Add setDocComment() to Node interface
Previously it was only part of NodeAbstract.
2016-10-21 23:26:51 +02:00
Matthew Brown
623bad2c8b Type encapsulated string parts specifically 2016-10-21 11:46:54 +02:00
Matthew Brown
f66cf8f0dd $name can be null for PHP 7 anonymous classes 2016-10-21 11:46:14 +02:00
Nikita Popov
a46b309975 Move constants into NodeTraverser class
Not that the interface makes much sense anyway, but these are
implementation details of a specific traverser.
2016-10-16 22:13:09 +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
2be7838fc6 Correctly assign attrs for encaps vars 2016-10-08 23:58:39 +02:00
Nikita Popov
f6eb341b15 Fix GroupUse prefix attribute assignment 2016-10-08 23:55:46 +02:00
Nikita Popov
b2fe43cf7a Next try... 2016-09-30 21:06:48 +02:00
Nikita Popov
648a246be0 Next try to fix HHVM build 2016-09-30 20:57:21 +02:00
Nikita Popov
5025d75160 Try to fix HHVM build 2016-09-30 20:33:56 +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
e926efd62e Fix regex 2016-09-30 19:17:10 +02:00
Nikita Popov
17d1e738fa Don't use ~__EMU sequences in emulative lexer
These were necessary back in the day when we had to emulate some
complex functionality such as nowdoc strings. Now we can simply
directly translate certain token sequences.

The motivation for this change is to avoid preprocessing of the source
code, which would complicate offset-aware error handling inside the
lexer as offsets would no longer be correct.
2016-09-30 19:10:16 +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