1740 Commits

Author SHA1 Message Date
Amirreza Nasiri
5973c30a46 Update JSON_representation.markdown
Fix the invalid JSON structure
2024-07-13 15:46:21 +02:00
Nikita Popov
b917ba7b9c Add PHP 8.4 to CI matrix
Not using it in the integration tests yet.
2024-07-13 11:11:15 +02:00
Nikita Popov
caf540443a Declare PHP 8.4 as the newest supported version
As the comment indicates, this includes partially supported
versions. PHP-Parser includes support for all parts of PHP 8.4
that have landed in php-src.
2024-07-13 11:10:30 +02:00
Nikita Popov
683130c2ff Release PHP-Parser 5.1.0 v5.1.0 2024-07-01 22:03:41 +02:00
Nikita Popov
a894652a3d Fix ternary precedence printing
The precedence table set the LHS and RHS precedence for the
ternary to -1, which is the dummy value used for unary operators.
Instead, it should be the same as the operator precedence, as
the ternary is non-associative since PHP 8.

Fixes #1009.
2024-07-01 21:51:42 +02:00
Jing Xu(RainX)
3ef0811e45 Fix a typo: Dereferencable to Dereferenceable 2024-06-12 20:31:58 +02:00
Jing Xu(RainX)
db1963f9ea Fix a typo: Dereferenceing to Dereferencing 2024-06-12 20:29:11 +02:00
Jorg Adam Sowa
daaadc3bae
Adjust tests to be compatible with PHPUnit 10 (#998)
This avoids warnings on PHPUnit 10, without actually
switching to PHPUnit 10.
2024-06-03 08:24:19 +02:00
Nikita Popov
7b0384cdbe [8.4] Add support for new deref without parens
RFC: https://wiki.php.net/rfc/new_without_parentheses
2024-05-31 23:07:44 +02:00
Jorg Adam Sowa
d57da64d7c
Add missing void return types (#997) 2024-05-31 09:32:45 +02:00
Jorg Sowa
d327cf2acf Updated actions/checkout to v4 2024-05-21 18:12:19 +02:00
Markus Staab
c5ee33df86
Declare more precise phpdoc types (#993) 2024-04-19 21:04:10 +09:00
Nikita Popov
46be4560c4 Use PHP 8.3 for more CI jobs 2024-03-17 11:24:36 +01:00
Markus Staab
f2e037f8ea Make phpunit fail on deprecation warnings (#989)
(cherry picked from commit 4d36e9c16f4820c2ed9360bc818982f3c02a08f5)
2024-03-17 10:06:45 +01:00
Nikita Popov
b43758e9e9 Remove PHPUnit 7 and 8
PHPUnit 9 supports all the PHP versions that we need. Also update
the PHPUnit config schema.
2024-03-17 09:31:05 +01:00
Markus Staab
09691fc86e Prevent off-by-one errors in line-number related methods 2024-03-13 20:24:50 +01:00
Nikita Popov
139676794d Release PHP-Parser 5.0.2 v5.0.2 2024-03-05 21:51:40 +01:00
Nikita Popov
70c96493b4 Fix indentation detection after opening tag
Fixes #982.
2024-03-02 18:59:44 +01:00
Maarten Buis
ec02613432 Update PhpVersion::getNewestSupported() to PHP 8.3 2024-03-02 08:27:21 +01:00
Nikita Popov
af14fdb282 Avoid cyclic reference in parser
Pass $this as an explicit $self argument to the reduce callbacks,
so we can make them static. This avoids a circular reference in
the parser, so that it can be immediately destroyed when it goes
out of scope.

Fixes #980.
2024-02-21 21:13:45 +01:00
Nikita Popov
2218c2252c Release PHP-Parser 5.0.1 v5.0.1 2024-02-21 20:24:10 +01:00
sasezaki
ce019e9ad7 Add dev tool files to export-ignore 2024-01-14 10:02:54 +01:00
Nikita Popov
ff095c3c65 Check for tokens with non-integer ID
Fixes #974.
2024-01-10 20:34:09 +01:00
Nikita Popov
d619c8b4e6 Fix typo in upgrading guide
Fixes #973.
2024-01-09 20:23:09 +01:00
Nikita Popov
eb036d5a09 Add instructions for adding new syntax support 2024-01-07 18:54:10 +01:00
Nikita Popov
4a21235f7e Update documentation links in README v5.0.0 2024-01-07 18:17:35 +01:00
Nikita Popov
fba1d621c0 Release PHP-Parser 5.0.0 2024-01-07 18:14:20 +01:00
Nikita Popov
5cc5a67004 Upgrading guide tweaks 2024-01-07 18:11:19 +01:00
Nikita Popov
f603e19336 Avoid PHPUnit deprecation warnings 2024-01-07 17:46:24 +01:00
Ondrej Mirtes
1eeeb2d525 Fix parent class of PropertyItem and UseItem 2023-12-22 19:57:32 +01:00
Nikita Popov
255000ad49 Release PHP-Parser 5.0.0rc1 v5.0.0rc1 2023-12-20 22:32:29 +01:00
Nikita Popov
f7d484aa0e Fix handling of empty input
Fixes #967.
2023-12-20 21:51:46 +01:00
Nikita Popov
f82a6365a5 Add upgrading nodes for changes since beta1
Fixes #965.
Fixes #966.
2023-12-20 21:36:53 +01:00
Ondřej Mirtes
13a41f05a7 Fix typos in UPGRADE-5.0.md 2023-12-17 21:03:53 +01:00
Ondrej Mirtes
f66650073c Fix NameResolver for class constant native type 2023-11-28 20:10:53 +01:00
Nikita Popov
d0b35126e7 Update CHANGELOG 2023-11-12 17:06:58 +01:00
Nikita Popov
3640d18b87 Remove ParserFactory::create()
Don't try to keep backwards-compatibility with the old factory
style, which doesn't map cleanly onto supported options (we only
have ONLY_PHP7/PREFER_PHP7, which should probably create a Php8
parser in terms of how they are used, but this would no longer
match their names).

Instead, I have backported the new createForNewestSupportedVersion()
and createForHostVersion() methods to PHP-Parser 4.
2023-11-12 16:52:30 +01:00
Théo FIDRY
b54302f363 build: Exclude grammar from export git artifact
(cherry picked from commit 402b6cf3452c21c58aa11d9549cee6205d14e347)
2023-11-12 13:04:04 +01:00
Nikita Popov
acfccd9d74 Run with updated php-cs-fixer 2023-11-01 18:50:25 +01:00
Sandro Gehri
eabae1f7fa Fix typo 2023-11-01 18:45:07 +01:00
xjaja
8d50e9d066 Don't drop class statements before error (#952)
When encountering a null statement (indicating that an error occurred),
retain the preceding statements. These were accidentally dropped
previously.

(cherry picked from commit 54103d838734be0499172026525e38cbf6af2711)
2023-10-07 12:22:01 +02:00
Abdul Malik Ikhsan
481fec47f4 Improve performance of find() and findFirst() when passed $nodes is empty array 2023-10-07 12:11:47 +02:00
Nikita Popov
4e27a17cd8 Use visitor to assign comments
This fixes the long-standing issue where a comment would get assigned
to all nodes with the same starting position, instead of only the
outer-most one.

Fixes #253.
2023-09-28 21:45:08 +02:00
Nikita Popov
de84f76766 Avoid by-reference iteration in NodeTraverser
No need to create reference wrappers around every element in the
array.
2023-09-26 20:25:37 +02:00
Nikita Popov
b4183c2b09 Remove Stmt\Throw
This was a backwards-compatibility shim for Expr\Throw.
2023-09-25 18:37:07 +02:00
Nikita Popov
a1ccf57727 Introduce Stmt\Block
Stmt\Block will be created for { $a; } style blocks, unless these
occur directly inside some structure that is usually combined
with a block.

For example if ($a) { $b; } will continue to use the old
representation (plain array in in If_::$stmts), but a free-standing
{ $b; } will become a Stmt\Block.

Fixes #590.
2023-09-24 21:13:01 +02:00
Nikita Popov
f5adbb5e3f Add rawValue to InterpolatedStringPart and doc strings
For doc strings, the rawValue (on either the String_ or
InterpolatedStringPrts) does not include the leading indentation
(which is available as docIndentation) or the trailing newline on
the last part.
2023-09-24 12:55:38 +02:00
Nikita Popov
5edc190bda Add support for dumping additional attributes 2023-09-23 21:36:57 +02:00
Nikita Popov
80851163a6 Assemble NodeDumper result in property
Append to a property instead of returning strings. This is
significantly faster when dumping large ASTs.

This also fixes an inconsistency where the indentation level for
strings and comments was off-by-one.
2023-09-23 20:38:53 +02:00
Nikita Popov
8f175fe7c8 Pass --dry-run to php-cs-fixer
Apparently it only returns the correct exit code with the
--dry-run option.
2023-09-23 18:38:52 +02:00