Nikita Popov
35306de32f
Support visibility modifiers in namespaced names
...
Fixes #704 .
2020-08-29 16:35:31 +02:00
Nikita Popov
ad365b1beb
FPPP: Fix code block detection during removal
...
Instead of checking whether there is a {/} before/after the removed
note, check whether {/} occurs in the between-node range. Dropping
that is what we're really concerned about here.
2020-08-29 16:28:28 +02:00
Ondrej Mirtes
fd6052e37d
FPPP failing tests
2020-08-23 20:54:01 +02:00
Nikita Popov
bd722809f7
FPPP: Support removing nodes from start of list
2020-08-23 17:35:37 +02:00
Nikita Popov
8bcaa4261e
Add parens for new/instanceof with complex expression
...
This is not fully accurate because the rules for "new variables"
are different than the rules for dereferenceable LHS.
2020-08-09 22:07:33 +02:00
Nikita Popov
feb6bf7a0c
Wrap class const LHS in parens if necessary
...
This looks like a very old bug in the pretty printer that showed
up in PHP 8 tests.
2020-08-09 21:41:30 +02:00
Nikita Popov
0cee2088ea
Remove self/parent/static restriction for namespace names
...
This no longer applies as of PHP 8.0.
2020-08-09 21:21:22 +02:00
Nikita Popov
78e08fc178
Allow keywords in namespace declaration
2020-08-09 21:19:59 +02:00
Nikita Popov
3aadc15e2e
Support keywords in namespaced names
2020-08-09 21:11:49 +02:00
Nikita Popov
a98350581c
Add support for throw expression
2020-08-09 20:52:55 +02:00
Nikita Popov
7f398769a0
Add support for static return type
2020-08-09 18:52:32 +02:00
Nikita Popov
98f7f39d1c
Add named argument support
...
Not adding any explicit FPPP support, as I don't think add/remove
of names can be handled any better than full reformatting.
2020-08-09 17:37:44 +02:00
Nikita Popov
23d9c17770
Add support for nullsafe operator
2020-08-09 12:08:05 +02:00
Nikita Popov
f6bf041583
Remove last uses of MockBuilder
2020-08-08 11:58:00 +02:00
Nikita Popov
1bf073a76c
Avoid most MockBuilder uses in NodeVisitor testing
...
This removes all the warnings about at() usage ... even though
it is still used. Apparently warnings don't get emitted if the
at() usage is inside a data provider?
2020-08-08 11:49:05 +02:00
Nikita Popov
1721ae155c
Avoid one use of MockBuilder
...
We can just use anon classes here and avoid PHPUnits unreliable
MockBuilder.
2020-08-08 11:49:05 +02:00
Nikita Popov
f845568e1d
Remove an unnecessary use of at()
2020-08-07 10:19:39 +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
a63b495fe6
Migrate grammar to use PHP 8 T_NAME_* tokens
...
This will break everything on PHP < 8.
2020-07-23 12:01:50 +02:00
Nikita Popov
2d1998938c
[PHP 8.0] Support trailing comma in closure use list
...
RFC: https://wiki.php.net/rfc/trailing_comma_in_closure_use_list
2020-07-22 18:43:55 +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
17f478107a
Fix file name
2020-07-22 18:30:00 +02:00
Tomas Votruba
69c5d48afd
[PHP 8.0] Add match expressions ( #672 )
...
RFC: https://wiki.php.net/rfc/match_expression_v2
Upstream implementation: php/php-src#5371
Closes #671 .
2020-07-15 21:40:05 +02:00
Sebastian Bergmann
f545f18a87
Add ParentConnectingVisitor and NodeConnectingVisitor ( #681 )
2020-07-11 11:31:43 +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
TomasVotruba
b58b19ed1d
Add constructor promotion support
2020-06-27 17:57:47 +02:00
Nikita Popov
0d2d8f95a1
FPPP: Support catch without variable
2020-06-27 17:42:46 +02:00
TomasVotruba
244db65dd1
[PHP 8.0] Add trailing comma in parameter list
2020-06-12 20:24:25 +02:00
TomasVotruba
b5f5313d73
[PHP 8.0] Add exception witout variable
2020-06-03 09:18:13 +02:00
Máté Kocsis
32f89662f3
Add support for the mixed type
2020-05-28 23:39:04 +02:00
Nikita Popov
d86ca0f745
Support arbitrary expressions in new/instanceof
2020-02-22 21:09:03 +01:00
Nikita Popov
c8d1216531
Treat magic constants like normal constants
2020-02-22 21:06:03 +01:00
Nikita Popov
8999a13cb2
Make class constants fully dereferencable
2020-02-22 21:03:53 +01:00
Nikita Popov
c1eaa0d5cd
Unify array and object dereferencability
2020-02-22 20:57:39 +01:00
Nikita Popov
ca5f7c9761
Split productions, unify {} dereferencing
2020-02-22 20:54:55 +01:00
Nikita Popov
ad696ee75d
Make encapsed strings fully dereferencable
2020-02-22 20:49:11 +01:00
Nikita Popov
6770deda3d
Check that ::class on object works
2020-02-22 20:42:11 +01:00
Nikita Popov
568236a305
Allow expressions in list()
...
Similar to the previous commit: list() syntactically accepts any
expression and non-variables are compile-time errors. The special
case of ($a) ends up being legal by accident.
2020-02-19 21:29:17 +01:00
Nikita Popov
9dda080a9d
Allow expressions in isset()
...
Partial fix for #653 . PHP 7 allows expressions inside isset(), but
rejects non-variables in the compiler. A side-effect of this is that
isset(($x)) is allowed, though this is not intentional.
2020-02-19 21:14:33 +01:00
Nikita Popov
3ec87ef757
Don't require doc comment to be last comment
...
Fixes #652 .
2020-02-15 10:52:34 +01:00
Ruud Kamphuis
64f4d5b619
Add getProperty
to ClassLike
2020-02-09 22:43:42 +01:00
Nikita Popov
f56d90d4f8
Add additional tests for modifying a Nop comment
2020-02-09 17:23:42 +01:00
Nikita Popov
46cbd9393a
Place Nop nodes more precisely
...
If the Nop is created to collect comments, place it directly after
the comment, instead of at the next non-whitespace character.
2020-02-09 17:10:33 +01:00
Nikita Popov
602af9060d
Add end line / file position / token position to comments
2020-02-09 16:53:46 +01:00
Nikita Popov
bf086d9833
FPPP: Remove special Nop handling
...
This results in ugly formatting, but avoids generating invalid
code.
2020-02-09 16:17:12 +01:00
Ryan Weaver
521addec91
Adding a test case for Nop causing bad new statement placement
2020-02-09 16:16:38 +01:00
Tomáš Votruba
88f3a669c1
Add union type to ParamBuilder and BuilderHelpers
2020-01-05 00:34:49 +01:00
Nikita Popov
664c10121e
Add support for union types
...
We definitely need to introduce a general "Type" abstraction in
the next major version.
2019-11-08 14:45:32 +01:00
Tomas Votruba
006acba066
add getTraitUses() method to ClassLike
2019-08-31 09:26:51 +02:00
Tomas Votruba
005bb1dba7
add getProperties() and getConstants() to ClassLike
2019-08-30 20:47:14 +02:00
Tomáš Votruba
3f718ee2c3
[PHP 7.4] Add support for numeric literal separators ( #615 )
...
Implements RFC https://wiki.php.net/rfc/numeric_literal_separator .
Closes #614 .
2019-06-30 12:13:28 +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
9484baf8f8
Make compatible with PhpUnit 8
2019-06-23 15:03:40 +02:00
hoels
624f71fa6f
Resolve return type of arrow functions ( #613 )
2019-06-04 16:25:12 +02:00
Nikita Popov
94d93f27a5
Revert "Recover from error inside alternative array deref syntax"
...
This reverts commit 9d44edf85d
.
2019-05-24 22:58:13 +02:00
Nikita Popov
9d44edf85d
Recover from error inside alternative array deref syntax
...
This is to improve error recovery for cases like #545 .
2019-05-12 11:38:15 +02:00
Nikita Popov
aa72c5d674
FPPP: Support inserting into empty lists
2019-05-11 22:49:32 +02:00
Nikita Popov
60d025a914
Fix attributes for zero-length nop nodes
...
Previously zero-length nop nodes used the lookahead start attributes
and current end attributes. This choice ends up being somewhat weird,
because the end attributes will be the at the last non-whitespace,
non-comment token, which might be quite far back. More problematically,
we may not have encountered any non-discarded token if we're at the
start of the file, in which case we will have no end attributes to
assign.
Change things to use a canonical "zero-length" node representation,
where the end position (token & file) will be exactly one before the
start position.
Fixes #589 .
2019-05-11 20:01:25 +02:00
Nikita Popov
b2cecec6bc
Remove bogus exprStmt mode test
...
We're always generating expression statements nowadays, this flag
hasn't existed for a long while now...
2019-05-11 18:51:37 +02:00
Tomas Votruba
8012faea54
[PHP 7.4] Add array spread
2019-05-09 19:15:35 +02:00
Tomáš Votruba
f3b19c19ef
[PHP 7.4] Add support for arrow functions ( #602 )
...
Per RFC https://wiki.php.net/rfc/arrow_functions_v2 .
2019-05-09 14:17:28 +02:00
Tomas Votruba
9de96821f7
Add support for ??= operator
...
Introduced in PHP 5.4, represented using an AssignOp\Coalesce node.
2019-02-09 11:16:26 +01:00
Lars Moelleken
b7e6361536
updates via "rectorphp/rector" ( #573 )
...
- "global" -> remove unused "use" statements
- "phpunit" -> fix "@covers" comments
- "phpunit" -> replace "->will($this->returnValue()" with "->willReturn()"
- "UseTest.php" -> add missing namespace
- "composer.json" -> use "autoload-dev"
- remove -> "require_once" usage in the tests (use autoload-dev via composer.json)
-> most of the changes are done automatically by "https://github.com/rectorphp/rector "
2019-01-19 11:18:00 +01:00
Nikita Popov
d5180f0d95
Change test to use correct node type
...
Class name is an Identifier, not a Name.
2019-01-12 17:31:37 +01:00
Tomas Votruba
af8c729603
Add PHP 7.4 typed properties support
2019-01-05 21:34:25 +01:00
Tomas Votruba
0ef61b49bb
add float/double/real KIND support to Cast\Double node
2019-01-05 19:23:00 +01:00
Nikita Popov
90ee36a7fc
Actually remove assertion...
2018-12-26 14:19:18 +01:00
Nikita Popov
f42bbc2403
Avoid default action for error production
...
error is not necessarily going to have a semantic value, make sure
that the default action $$=$1 is not used.
Fixes #551 .
2018-11-30 11:00:48 +01:00
Nikita Popov
3d0f7843d4
Support error recovery for missing return type
...
The return type is set to "null" in this case.
Fixes #544 .
2018-10-25 16:56:50 +02:00
Maks Rafalko
dc323458b4
Add new constant to be returned from enterNode() to not traverse current and child nodes ( #536 )
...
* Add new constant to be returned from enterNode() to not travers current node for subsequent visitors and skip children traversing
* Allow visitors to replace nodes in leaveNode() when DONT_TRAVERSE_CURRENT_AND_CHILDREN is used
2018-10-08 22:26:00 +02:00
Tomáš Votruba
d638dd9b25
Use methods instead of annotations for expected exceptions ( #533 )
2018-09-22 10:43:54 +02:00
Nikita Popov
eebaa94647
Flexible doc strings: Fix some issues, add more tests
2018-09-22 10:09:00 +02:00
Nikita Popov
0ed9065b4c
Flexible doc: Validate and strip indentation
...
If indentation is invalid, we strip on a best-effort basis.
The error position information is not great, but I don't want to
introduce sub-token error positioning at this point in time.
2018-09-21 21:47:01 +02:00
Nikita Popov
5f73c4de80
Flexible doc: Validate end label indentation
...
Move doc string parsing logic from rebuildParsers.php and
String_::parseDocString() into ParserAbstract. This stuff is
going to get complicated now.
For now only implement the validation of the indentation on the
end label.
2018-09-21 16:31:17 +02:00
Nikita Popov
a5c726bfbf
Make sure heredoc end label not followed by label char
2018-09-21 11:44:39 +02:00
Nikita Popov
83766c8c0e
Partial support for flexible heredoc/nowdoc
...
This only implements the token emulation part, it does not yet
handle the indentation stripping.
Emulating this feature on old PHP versions is really tough and is
not going to work perfectly, but hopefully this implementation is
"good enough".
2018-09-21 11:16:00 +02:00
Nikita Popov
16c5d107ca
Revert "Add check for leading backslash in Name ctor"
...
This reverts commit 2f67429ec9
.
Reverting this to avoid a BC break in a patch release, will
reapply for the next major version.
2018-09-18 09:00:32 +02:00
Nikita Popov
41408081d7
Rename setTypeHint() to setType()
...
To align with modern terminology -- we don't like calling these
type hints anymore. Old method name remains, marked as @deprecated.
2018-07-22 21:41:21 +02:00
ProgMiner
d4a5a6e84b
Add tests for Builder\TraitUseAdaptation
2018-07-22 21:23:00 +02:00
ProgMiner
c55798ccc6
Add tests for Builder\TraitUse
2018-07-22 21:23:00 +02:00
ProgMiner
82e8b33814
Add some trait use factory builder integration tests
2018-07-22 21:23:00 +02:00
Nikita Popov
3e02eb7108
Fix updateTests.php
2018-07-22 21:18:34 +02:00
Nikita Popov
2f67429ec9
Add check for leading backslash in Name ctor
...
Fixes #523 .
2018-07-21 21:58:32 +02:00
Nikita Popov
0cd7207ca6
Add tests for var() and propertyFetch()
2018-07-20 21:59:42 +02:00
Nikita Popov
b855c1ca23
Add some tests for new use builders
2018-07-20 21:44:37 +02:00
Nikita Popov
8b1c9c0409
Store comment at end of class in Nop statement
...
Fixed #509 .
2018-07-07 12:49:49 +02:00
openex27
df64d86cf4
Check for empty $append in safeAppend()
...
Can happen with Nop statements.
2018-07-07 12:34:07 +02:00
Nikita Popov
aac539ef0a
Adjust test output
...
Whoops, forgot to commit this part.
2018-07-07 12:25:01 +02:00
Nikita Popov
f967b867d5
Improve error recovery in arrays
...
Similarly to missing semicolons, the error is not indicated in the
AST.
Fixes #512 .
2018-07-07 12:24:06 +02:00
Nikita Popov
6526ea2497
Throw when printin EncapsedStringPart
...
This needs to go through something like Encapsed or ShellExec to
determine quotation type. Explicitly throw an exception to avoid
getting an undefined method error.
2018-06-03 13:31:00 +02:00
Gabriel Caruso
21d27527ed
Use dedicated assertNull assertion ( #503 )
2018-05-19 11:12:07 +02:00
Nikita Popov
7b201b63d2
Error recovery for functions without body
2018-05-13 16:28:08 +02:00
Nikita Popov
01e85a26c6
Support recovery for param without variable
...
We store an Expr\Error for the variable in this case.
2018-05-12 19:49:39 +02:00
Nikita Popov
fa99c3fbfb
Recover from foreach without as
2018-04-28 22:31:45 +02:00
Nikita Popov
7208b1c7ac
Improve error recovery in classes ( #492 )
2018-03-30 16:03:03 +02:00
Nikita Popov
7f8ff1b9a4
Add support for list reference assignments
...
RFC: https://wiki.php.net/rfc/list_reference_assignment
2018-03-10 16:48:20 +01:00
Nikita Popov
91a462ce76
PHP 7.3: Add support for trailing commas in calls
...
RFC: https://wiki.php.net/rfc/trailing-comma-function-calls
2018-03-10 16:41:20 +01:00
Nikita Popov
610617fe93
Also add new() builder
2018-03-03 22:25:58 +01:00
Nikita Popov
ff2d85dc6b
Add constFetch() and classConstFetch() builders
2018-03-03 22:14:42 +01:00