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

812 Коммитов

Автор SHA1 Сообщение Дата
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
dantleech e5ebee7673
Use 340 for mixed reserved word
Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>
2020-12-23 17:19:04 +01:00
dantleech 0034e8127f
Update src/TokenKind.php
Co-authored-by: Tyson Andre <tyson.andre@uwaterloo.ca>
2020-12-23 17:17:23 +01:00
Daniel Leech 55436ce6b8 Deprecate IterableKeyword in favor of IterableReservedWord 2020-12-23 15:56:32 +00:00
Daniel Leech b08e0d5326 PHPStan no longer reports this error 2020-12-23 09:03:32 +00:00
Daniel Leech acdfa57cc5 Add support for PHP 8.0 mixed type 2020-12-23 08:53:56 +00:00
Rob Lourens f2ec9ea3bd
Merge pull request #348 from camilledejoye/fix/#191-iterable-as-token
[Feature] Support the php 7.1 iterable type hint as a unique token kind
2020-11-28 09:40:05 -08:00
Camille Dejoye 8430e6d304 iterable is now a token instead of a Name 2020-11-07 11:04:36 +01:00
Rob Lourens 1d76657e32
Merge pull request #345 from TysonAndre/goto-empty
Fix handling of named label for goto.
2020-09-13 12:29:12 -05:00
Rob Lourens b5c7cd4a7e
Merge pull request #346 from TysonAndre/attribute-group-missing-error
Warn about #[] attribute groups of 0 length
2020-09-13 12:11:49 -05:00
Tyson Andre 0c991bcdbb Warn about #[] attribute groups of 0 length
Each attribute group must have 1 or more elements.
The same approach is used for closure use element lists.

    php > #[] class X{}

    Parse error: syntax error, unexpected token "]" in php shell code
    on line 1
2020-09-13 11:54:43 -04:00
Tyson Andre 42ddd2104e Fix handling of named label for goto.
The label is a standalone statement just like any other statement.
It isn't associated with the next statement by PHP's parser.

E.g. `while (false) label: echo "test\n";` echoes "test".

Fixes #154
2020-09-12 20:49:40 -04:00
Rob Lourens 85b40c3855
Merge pull request #344 from TysonAndre/travis-nightly
Start running tests in travis with nightly
2020-09-12 17:15:27 -05:00
Rob Lourens c91c8a1605
Merge pull request #342 from TysonAndre/anonymous-class-attributes
Also handle attributes in `new #[MyAttr] class {...}`, traits, interfaces
2020-09-12 13:13:42 -05:00
Tyson Andre 494acd8812 Start running tests in travis with nightly
Whenever Travis provides a stable 8.0 label, that can be switched to.
Currently, though, that's not available. 8.0snapshot could not be
installed when I tried.

PHPUnit is too outdated for it to support 8.0.

Yaml treats `:` as a dictionary, so use the multi-line string syntax.
2020-09-12 09:04:11 -04:00
Tyson Andre ba3805be97 Fix infinite loop parsing `trait #[`
Fixes #343
2020-09-12 08:44:00 -04:00
Tyson Andre 6d546ce07a Support attributes on traits and interfaces
They were already supported on ClassDeclaration.
The php runtime allows attributes on all classlikes,
including traits/interfaces.
2020-09-10 20:44:26 -04:00
Tyson Andre 4e9127ce28 Also handle `new #[MyAttr] class {...}`
I forgot that anonymous classes were parsed into an
ObjectCreationExpression instead.

Also support attributes there, cause a diagnostic to be emitted if the
attribute group(s) aren't followed by the `class` keyword.

For #320
2020-09-10 20:33:05 -04:00
Rob Lourens 917e065898
Merge pull request #341 from TysonAndre/attributes-group
Add support for PHP 8.0 `#[` attribute groups
2020-09-10 10:58:28 -05:00
Tyson Andre 673bacf4b2 Improve the lookahead check for attributes on expressions 2020-09-06 11:29:00 -04:00
Tyson Andre 3a174a95ab Add support for php 8.0 `#[` attribute groups
This supports the grouped attributes syntax that will be in PHP
8.0.0RC1.
See
https://wiki.php.net/rfc/shorter_attribute_syntax_change#secondary_vote

Fixes https://github.com/microsoft/tolerant-php-parser/issues/320
2020-09-06 09:57:14 -04:00
Rob Lourens 52e792ae27
Merge pull request #337 from PythooonUser/helper-function-on-modified-types
Refactoring modified type behaviors
2020-08-22 19:09:24 -07:00
Rob Lourens 8bb09599c6
Merge pull request #333 from PythooonUser/issue-178
Issue 178 - Declare Statement Directive List
2020-08-22 18:31:42 -07:00
Felix Siebeneicker 6b07addab5 Refactoring modified type behaviors 2020-08-10 16:20:57 +02:00
Felix Siebeneicker ec691a001d Making changes backwards compatible 2020-08-10 10:27:54 +02:00
Rob Lourens 3fdca6be0f
Merge pull request #335 from TysonAndre/named-arguments-
Support parsing php 8.0 named arguments
2020-08-08 16:25:34 -07:00
Tyson Andre 869dc7ff1b Support parsing php 8.0 named arguments
Adding to the properties in ArgumentExpression keeps this working
in older applications.

And modify unaryExpression11 to avoid conflict with attributes syntax

Fixes #334
2020-08-08 17:49:45 -04:00
Felix Siebeneicker a56215494f
Fixing start tag length by including whitespace tokens 2020-08-07 13:12:35 +02:00
Felix Siebeneicker b1e2ec09b6
💄 2020-08-07 11:22:52 +02:00
Felix Siebeneicker 63cf35a380
Updating existing test structures 2020-08-07 11:22:36 +02:00
Felix Siebeneicker ceb5125f73
Adding test case for simple list 2020-08-07 11:21:57 +02:00
Felix Siebeneicker 98fbbd206a
Adding declare directive list support 2020-08-07 11:21:14 +02:00