653757bec6
Nullable type declaration for default null value
...
Adds ? before type declarations for parameters with a default null value
2022-07-04 20:34:31 +02:00
c878d7195d
Move token mapping from lexer to parser
...
This allows a different token mapping per parser.
2022-06-19 18:05:52 +02:00
6e0eec807e
Move definition of compatibility tokens into separate file
2022-06-19 17:29:24 +02:00
aff98bbf16
Use PHP 8.0 token representation
...
Migrate everything to use PhpToken-compatible token representation,
rather than the legacy array/string representation.
2022-06-05 17:44:42 +02:00
55c4269232
Add support for new PHP 8.1 modifiers ( #796 )
...
Implement support for readonly properties (https://wiki.php.net/rfc/readonly_properties_v2 ) and
final class contstants (https://wiki.php.net/rfc/final_class_const ).
2021-07-21 12:43:29 +02:00
c758510a37
Add support for PHP 8.1
...
With the introduction of intersection types, PHP now lexes the
token '&' either as T_AMPERSAND_(NOT_)FOLLOWED_BY_VAR_OR_VARARG.
This completely breaks parsing of any code containing '&'.
Fix this by canonicalizing to the new token format (unconditionally,
independent of emulation) and adjusting the parser to use the two
new tokens.
This doesn't add actual support for intersection types yet.
2021-07-09 16:52:58 +02:00
4848a0d734
Check for \r as newline in closing tag
...
Fixes #761 .
2021-04-25 22:42:18 +02:00
a8223f228a
Add emulation for enum keyword
2021-03-20 17:49:44 +01:00
bc7a9bf9c2
Remove useless code left from old implementation
2020-12-02 12:54:15 +01:00
b9b65a2996
Fix check for token emulation conflicts
2020-09-26 12:29:16 +02:00
f66a32e2df
Emulate PHP 8 attribute syntax
...
Perform emulation by replacing #[ with %[, then patching % back
to # and coalescing #[ into T_ATTRIBUTE if it is a freestanding
token.
2020-09-06 17:42:38 +02:00
e3872b8906
Improve compatibility with other libs defining compat tokens
2020-09-06 15:00:28 +02:00
35306de32f
Support visibility modifiers in namespaced names
...
Fixes #704 .
2020-08-29 16:35:31 +02:00
3aadc15e2e
Support keywords in namespaced names
2020-08-09 21:11:49 +02:00
23d9c17770
Add support for nullsafe operator
2020-08-09 12:08:05 +02:00
1a1300aa2a
Add reverse emulation support
2020-08-01 22:34:36 +02:00
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
739b4b4c60
Fix handling of unterminated comment with trailing newline
...
Fixes #688 .
2020-07-22 18:35:55 +02:00
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
602af9060d
Add end line / file position / token position to comments
2020-02-09 16:53:46 +01:00
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
4fd36b9946
Fix compatibility with T_BAD_CHARACTER in PHP 7.4
2019-08-12 22:10:02 +02:00
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
a167aa2061
Optimize attribue checks in the lexer
2019-05-12 15:26:26 +02:00
e0a2043089
[CS] Space before casting
2018-01-13 16:03:57 +01:00
5285df8f22
[CS] Use elseif instead of else if
...
Conflicts:
lib/PhpParser/TokenStream.php
2018-01-13 16:03:36 +01:00
fa174b093f
Merge branch '3.x'
2017-11-13 01:15:38 +01:00
94ca9a7ab9
Use Tokens::class in lexer
...
Ref #441 .
2017-11-13 01:14:55 +01:00
68e9b91e9c
Use fully-qualified names for global constant references
2017-11-10 23:33:12 +01:00
47c973b3aa
Store start token position in comments
2017-11-04 17:45:14 +01:00
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
e2e99f269b
Add strict_types to lib code
2017-08-18 23:00:13 +02:00
ec535ea14e
[cs] use PHP 5.4 short array, since PHP 7.0 is min version
2017-08-13 21:14:28 +02:00
7646b31907
Merge branch '3.x'
2017-06-03 15:18:44 +02:00
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
b2c6497d63
Remove undefined variable hack
...
No longer necessary, as we don't support PHP 5 anymore.
2017-05-07 19:57:24 +02:00
a32e3797d4
Generate PHP 7 type annotations
2017-04-28 21:40:59 +02:00
9857a545e2
Remove unused variables ( #357 )
2017-02-11 11:05:36 +01:00
329e90c239
Improve doc comments
2017-02-09 20:49:52 +01:00
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
e3b87f40aa
Add non-void return types
2017-01-25 23:32:50 +01:00
bcdfb703d5
Cleanup imports
...
Thanks PhpStorm :)
2016-11-23 22:58:18 +01:00
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
b2fe43cf7a
Next try...
2016-09-30 21:06:48 +02:00
648a246be0
Next try to fix HHVM build
2016-09-30 20:57:21 +02:00
5025d75160
Try to fix HHVM build
2016-09-30 20:33:56 +02:00
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
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
b31a973fa7
Another fix for B"" handling
...
The lexer fix also need to account for uppercase B.
2016-04-04 22:07:50 +09:00
35011d2e4d
Deduplicate attribute assignment code a bit
2016-04-02 08:02:58 +09:00