Commit Graph

63 Commits

Author SHA1 Message Date
Nikita Popov
e3872b8906 Improve compatibility with other libs defining compat tokens 2020-09-06 15:00:28 +02:00
Nikita Popov
35306de32f Support visibility modifiers in namespaced names
Fixes #704.
2020-08-29 16:35:31 +02:00
Nikita Popov
3aadc15e2e Support keywords in namespaced names 2020-08-09 21:11:49 +02:00
Nikita Popov
23d9c17770 Add support for nullsafe operator 2020-08-09 12:08:05 +02:00
Nikita Popov
1a1300aa2a Add reverse emulation support 2020-08-01 22:34:36 +02:00
Nikita Popov
acaf3fecad Implement emulation of PHP 8 T_NAME_* tokens
Like comment emulation, this is unconditional, as it is required
for core functionality.
2020-07-23 12:28:13 +02:00
Nikita Popov
739b4b4c60 Fix handling of unterminated comment with trailing newline
Fixes #688.
2020-07-22 18:35:55 +02:00
Nikita Popov
4abc531213 Canonicalize to PHP 8 comment token format
The trailing newline is no longer part of the comment token.
2020-06-27 18:53:09 +02:00
Nikita Popov
602af9060d Add end line / file position / token position to comments 2020-02-09 16:53:46 +01:00
Nikita Popov
0a80b2d8ee Fix PHP 8 compatibility
This is a fix to preserve current behavior, but this should be
changed towards doing the same as PHP 8 does.
2019-10-19 10:49:37 +02:00
Nikita Popov
4fd36b9946 Fix compatibility with T_BAD_CHARACTER in PHP 7.4 2019-08-12 22:10:02 +02:00
Nikita Popov
b9b45dd2bc Insert T_BAD_CHARACTER tokens for missing characters
The token stream should cover all characters in the original code,
insert a dummy token for missing illegal characters. We should
really be doing this in token_get_all() as well.
2019-06-30 11:43:48 +02:00
Nikita Popov
a167aa2061 Optimize attribue checks in the lexer 2019-05-12 15:26:26 +02:00
Gabriel Caruso
e0a2043089 [CS] Space before casting 2018-01-13 16:03:57 +01:00
Nikita Popov
5285df8f22 [CS] Use elseif instead of else if
Conflicts:
	lib/PhpParser/TokenStream.php
2018-01-13 16:03:36 +01:00
Nikita Popov
fa174b093f Merge branch '3.x' 2017-11-13 01:15:38 +01:00
Nikita Popov
94ca9a7ab9 Use Tokens::class in lexer
Ref #441.
2017-11-13 01:14:55 +01:00
Nikita Popov
68e9b91e9c Use fully-qualified names for global constant references 2017-11-10 23:33:12 +01:00
Nikita Popov
47c973b3aa Store start token position in comments 2017-11-04 17:45:14 +01:00
Nikita Popov
a02990a39a Remove PHP 5 substr() workaround
In PHP 7 it no longer returns false instead of '' in this case.
2017-09-29 17:51:44 +02:00
TomasVotruba
e2e99f269b Add strict_types to lib code 2017-08-18 23:00:13 +02:00
TomasVotruba
ec535ea14e [cs] use PHP 5.4 short array, since PHP 7.0 is min version 2017-08-13 21:14:28 +02:00
Nikita Popov
7646b31907 Merge branch '3.x' 2017-06-03 15:18:44 +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
Nikita Popov
b2c6497d63 Remove undefined variable hack
No longer necessary, as we don't support PHP 5 anymore.
2017-05-07 19:57:24 +02:00
Nikita Popov
a32e3797d4 Generate PHP 7 type annotations 2017-04-28 21:40:59 +02:00
Matthew Brown
9857a545e2 Remove unused variables (#357) 2017-02-11 11:05:36 +01:00
Matthew Brown
329e90c239 Improve doc comments 2017-02-09 20:49:52 +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
bcdfb703d5 Cleanup imports
Thanks PhpStorm :)
2016-11-23 22:58:18 +01: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
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
ec614c95dd Add hasLeadingNewline attribute to InlineHTML
Use this attribute to not print an extra newline if the original
code did not have it.
2016-07-25 16:44:25 +02:00
Nikita Popov
b31a973fa7 Another fix for B"" handling
The lexer fix also need to account for uppercase B.
2016-04-04 22:07:50 +09:00
Nikita Popov
35011d2e4d Deduplicate attribute assignment code a bit 2016-04-02 08:02:58 +09:00
Nikita Popov
15a2388d75 Add start file offset to Comments 2016-04-02 07:54:01 +09:00
Nikita Popov
f493219c7d Move "kind" attribute handling out of lexer
Doesn't belong there and will cause issue with multiple assignments.
2016-03-10 12:55:15 +01:00
Nikita Popov
ae30f97af6 Add "kind" attribute to LNumbers
Kind specifies whether the number was formatted as decimal, octal,
binary or hex. The pretty printer reproduces the number kind (but
not necessarily the exact formatting).
2016-03-09 21:10:55 +01:00
Nikita Popov
47c342a3e4 Add "kind" attribute to Stmt\Exit_
Attribute specifies whether this is a "die" or an "exit" and the
pretty printer behaves accordingly.
2016-03-09 20:20:36 +01:00
Nikita Popov
75cd4ab7a5 Use error_clear_last() on PHP 7
Instead of the ugly undefined variable hack
2015-11-21 22:27:56 +01:00
Nikita Popov
f872fa9b0b Merge branch '1.x' 2015-07-04 14:40:53 +02:00
Nikita Popov
d5668f536d Fix __HALT_COMPILER_OFFSET__ support on HHVM 2015-07-04 13:15:48 +02:00
Nikita Popov
9c9a8cddce Merge branch '1.x' 2015-06-20 12:34:36 +02:00
Nikita Popov
fd7ee2e083 Add missing regex anchor 2015-06-20 12:34:10 +02:00
Nikita Popov
179d32cfaf Simplify handleHaltCompiler() implementation
Nowadays we're already tracking the filePos, no need to
recompute it.
2015-06-20 12:33:33 +02:00
Nikita Popov
bc21514ecf Move token constants into separate class
As these are shared between Php5 and Php7 parsers they should be
in some common place, otherwise we'd have to always reference either
one or the other.
2015-06-13 18:39:55 +02:00