Граф коммитов

893 Коммитов

Автор SHA1 Сообщение Дата
Tyson Andre 0d46605f06 Add test cases of void/never in parameter types 2022-08-23 08:11:51 -04:00
Tyson Andre c940402c01 Support php 'never' type, change parsing of 'void'
Similar to 'void', it's a compile time error to use void as a
parameter/property type, not a parse time error.
But `static` is a parse error.
(It can also be used in union types)

Remove redundant tokens added to merged returnTypeDeclarationTokens

Closes #373
Closes #372
2022-08-23 08:09:44 -04:00
Tyson Andre ca256f14d9 Remove inapplicable TODOs 2022-08-23 08:06:18 -04:00
Tyson Andre 3b81f38fee Fix parent node set when parsing union types 2022-08-23 08:06:18 -04:00
Tyson Andre 81790cde8b Stricten error checking in parsing union types/intersection types 2022-08-23 08:06:18 -04:00
Tyson Andre 18d7801aa3 Support php 8.2 `A|(B&C)` dnf types
Support php 8.2's Disjunctive Normal Form Types
(allowing parenthesized intersection types of 2 or more types in union types)
https://wiki.php.net/rfc/dnf_types

Closes #372
2022-08-23 08:06:17 -04:00
Rob Lourens 12612753fb
Merge pull request #370 from TysonAndre/test-8.1
Set up github workflows for multiple php versions
2022-08-22 23:06:17 -05:00
Tyson Andre dd25257480 Add .sh extension to run_tests files 2022-08-18 18:57:24 -04:00
Tyson Andre 6a89b5cab5 Set up github workflows for multiple php versions
Run this alongside Travis CI
2022-08-18 18:56:10 -04:00
Rob Lourens 9bf66371b9
Merge pull request #368 from TysonAndre/php8.2-features
Support php 8.2 readonly classes, constants in traits, `true` type
2022-08-18 12:08:00 -05:00
Rob Lourens e42180cb9a
Merge pull request #371 from TysonAndre/test-8.1-travis
Start testing in php 8.1 in travis
2022-08-18 11:37:39 -05:00
Rob Lourens a2f34af5f2
Merge pull request #369 from TysonAndre/remove-todo-230
Remove a TODO that no longer applies in php 8.0
2022-08-18 11:35:54 -05:00
Tyson Andre f08d13385e Start testing in php 8.1 in travis 2022-08-10 20:35:44 -04:00
Tyson Andre af944a3742 Remove a TODO that no longer applies in php 8.0
Any expression can be used as of 8.0 without an unexpected syntax error.

In encapsulated strings,
`"${a->prop}"` is equivalent to `"{${(a->prop)}}"` in php 8.0 and a
syntax error in previous php versions.

(Get the property `prop` of the global constant `a` (constants can be
objects in php 8.1), then get the variable with the name equal to that
string)
2022-08-10 19:35:18 -04:00
Tyson Andre 7ff8145300 Support php 8.2 true type
https://wiki.php.net/rfc/true-type
2022-08-08 20:26:50 -04:00
Tyson Andre 17a63a0e33 Add tests of php 8.2 constants in traits 2022-08-08 20:26:50 -04:00
Tyson Andre db0840e22b Update test expectations, test readonly class 2022-08-08 20:26:40 -04:00
Tyson Andre 2ba725bc6f Support PHP 8.2 features 2022-08-08 20:26:40 -04:00
Rob Lourens ecc2be15c1
Merge pull request #366 from zobo/fix-match-keyword
fix: add match to keywords
2022-06-24 09:16:11 -07:00
Damjan Cvetko 477b35899e
fix: add match to keywords 2022-06-24 11:04:59 +02:00
Rob Lourens f4f5e93032
Merge pull request #364 from dantleech/callable_function
callableExpression can also be a QualifiedName...
2022-01-03 16:54:28 -08:00
Daniel Leech adf34befa6 callableExpression can also be a QualifiedName...
...when the callable expression is a function

Fix typo
2022-01-03 23:24:54 +00:00
Rob Lourens 12db2d7319
Merge pull request #363 from TysonAndre/fix-deprecation
Fix PHP 8.2 deprecation notices in tolerant-php-parser
2021-11-29 11:13:38 -08:00
Tyson Andre c11175a0eb Fix PHP 8.2 deprecation notices in tolerant-php-parser
https://wiki.php.net/rfc/deprecate_dynamic_properties
was approved and merged into php 8.2.

Dynamic (undeclared) properties will be forbidden without
`#[AllowDynamicProperties]` in the next major release (9.0).

A separate followup question would be whether to include
`#[AllowDynamicProperties]` on the Node class declaration
or to instead do something similar to nikic/php-parser and add a dedicated
attributes array property for any applications using this library to
track state on nodes.

Fix phpstan notice
2021-11-27 13:41:27 -05:00
Rob Lourens af2ff38cc8
Merge pull request #361 from TysonAndre/fix-delimiter-edge-case
Fix parsing of `a ? a ? a : b : b`
2021-10-11 18:56:31 -07:00
Tyson Andre cbbaba14ca Fix parsing of `a ? a ? a : b : b`
Closes #360

Improve 75189fd29b - distinguish between
what might be the if node of a ternary expression and what can't be.
2021-10-08 09:53:38 -04:00
Rob Lourens 2e3999f22c
Merge pull request #359 from ishan-deepsource/patch-1
fix: Download the VSIX URL
2021-09-16 14:33:09 -07:00
Ishan Vyas 5f5c958538
fix: Download the VSIX URL 2021-09-16 20:15:23 +05:30
Rob Lourens 4f5a6ea3fc
Merge pull request #358 from TysonAndre/fix-delimiter-edge-case
Fix regression after supporting intersection types
2021-07-20 20:15:00 -07:00
Tyson Andre e0d0880739 Fix regression after supporting intersection types
checkToken only supports an integer, but started getting passed an array
after supporting intersection types (`['|', '&']`).

Fix a few other type signatures
2021-07-20 18:44:27 -04:00
Rob Lourens 6a965617cf
Merge pull request #357 from TysonAndre/readonly-properties
Support php 8.1 readonly property modifier RFC
2021-07-16 14:28:12 -07:00
Tyson Andre 78a7744214 Remove comment indicating unsupported modifiers 2021-07-16 17:06:08 -04:00
Tyson Andre 190ebc0463 Clarify why multiple modifiers can be parsed. Fix conflicts. 2021-07-16 16:48:27 -04:00
Tyson Andre 0faf367e46 Support proposed first-class callable syntax
Supports https://wiki.php.net/rfc/first_class_callable_syntax

It is possible that partial function application may allow mixing `...`
with other arguments in the future, if that passes.
See https://wiki.php.net/rfc/first_class_callable_syntax#syntax_choice

So modify the argument instead of replacing the entire argument list with the
token `...`
2021-07-16 16:46:20 -04:00
Tyson Andre e0814a0aeb Support readonly property modifier 2021-07-16 16:46:20 -04:00
Rob Lourens 03f8cabf77
Merge pull request #356 from TysonAndre/intersection-type-support
Support parsing PHP 8.1 intersection types
2021-07-16 12:41:19 -07:00
Rob Lourens 69f23cac94
Merge pull request #355 from PythooonUser/feature/issue-225
Error when calling getNamespaceDefinition on SourceFileNode
2021-07-11 19:00:05 -07:00
Tyson Andre 9067f71907 Support parsing PHP 8.1 intersection types
Pure intersection types were approved and merged into 8.1
https://wiki.php.net/rfc/pure-intersection-types

Note that this is permissive - php itself does not allow union types and
intersection types to be combined right now.

Fixes #354

Fixes parsing of references and bitwise `&` in php 8.1
2021-07-08 10:16:14 -04:00
Felix Siebeneicker 8fd46ab3ed
Adding source file node check 2021-06-22 21:07:40 +02:00
Rob Lourens 769b9d9b7a
Merge pull request #349 from TysonAndre/v1-refactor
Proposed changes for 0.1.0
2021-06-10 17:44:41 -07:00
Tyson Andre 56f2603a0d Support php 8.1 2021-06-03 20:08:17 -04:00
Tyson Andre 5df29efbf9 Convert array()/list() to short array `[]` with phpcbf
(Using short arrays for array destructuring requires php 7.1)
2021-04-29 17:30:38 -04:00
Tyson Andre 0b40640ac3 Refactor to use getStartPosition 2021-04-29 17:19:15 -04:00
Tyson Andre 465d02f146 v0.1.0: Raise minimum php version, change some AST representations
Raise the minimum php version from 7.0 to 7.2.
Depend on phpunit 8 for local development

Unify method names for Node and Token to getFullStartPosition and getStartPosition
(Consistently end public API methods with Position).
Avoid the need for callers to check if an object is a Node/Token before
calling a method.

Convert UnsetIntrinsicExpression to UnsetStatement - it can only be used
as a statement.

Unify previously split up lists into a single list in some AST node
properties (initially done that way for backward compatibility)

Clean up unnecessary special case for throw
- This continues to be parsed as an ExpressionStatement with the same
  precedence

Rename throwStatement to throwExpression in test file names.
2021-04-29 17:11:53 -04:00
Tyson Andre 2a48939763 [WIP] v1.0.0 proposal
Drop support for byRefToken in ArgumentExpression - it's a syntax error
in php 7.0+ and is prohibited in php 5.4+.

Convert the foo and otherFooList to fooList for union types in catch
name lists, parameters, properties, and return union types.

Remove ThrowStatement in favor of ThrowExpression for php 8.0.
Remove EchoExpression in favor of EchoStatement - echo cannot be used as
an expression.

Remove statement from NamedLabelStatement - it's always null since a
named label is a single statement by itself.

TODO: Consistently support MissingToken in a single-element list in cases where
a non-empty list is required, such as after `?` in types
(php 8.0 union types forbid combining `?` with multiple types)

TODO: Check for any regressions in diagnostics

TODO: Validate that this can be used with real projects
2021-04-29 16:38:40 -04:00
Rob Lourens 35646d5501
Merge pull request #352 from TysonAndre/enum-support
Support parsing PHP 8.1 enums
2021-03-29 18:53:02 -07:00
Rob Lourens dccc6f25ac
Merge pull request #328 from TysonAndre/update-composer
Support testing with phpunit 7 as well
2021-03-29 18:50:16 -07:00
Tyson Andre 5bfe9fdf0e Support parsing PHP 8.1 enums
Supports parsing https://wiki.php.net/rfc/enumerations

These tests pass locally after modifying the local installation of
phpunit 6 to workaround php 8.1 incompatibilities for `private function` and
$GLOBALS

Also, fix placeholder for T_NULLSAFE_OBJECT_OPERATOR prior to php 8.0.
This didn't matter in practice because
token_get_all never returns the constant that would be used in a key
prior to php 8.0

Enums are similar to classes, but:
- They forbid instance properties (and static properties)
- They allow `case` statements, which are the only allowed instances of
  the object. Those may or may not have an associated int/string type.
  The parse grammar seems to allow parsing any type
  but the compiler enforces that it's empty, an integer, or a string.
2021-03-27 16:41:04 -04:00
Tyson Andre b476ac70b2 Support testing with phpunit 7 as well
Prepare for testing with PHP 8.0

An alternative would be to drop support for php 7.0
2021-03-27 13:13:15 -04:00
Rob Lourens a38e03b87a
Merge pull request #350 from dantleech/mixed-reserved-word
Add support for PHP 8.0 mixed type
2020-12-30 11:04:20 -08:00