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
Nikita Popov
b998d1e9b5
Add funcCall(), methodCall() and staticCall() builders
2018-03-03 15:40:51 +01:00
Nikita Popov
6aba7624ed
Add replacement sanity check in traverser
2018-03-03 13:22:36 +01:00
Nikita Popov
ad9c42b66a
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php5.php
lib/PhpParser/Parser/Php7.php
2018-01-30 23:07:11 +01:00
Nikita Popov
08215e7646
Fix duplicate switch comment assignment
...
Fixes #469 .
2018-01-30 23:06:20 +01:00
Nikita Popov
a513ccabb7
Improve constant evaluation and add docs
...
Split into evaluateDirectly() and evaluateSilently(), to be able
to treat errors more gracefully. Add documentation for constant
evaluation.
2018-01-27 17:47:45 +01:00
Nikita Popov
6a273c9fbd
Remove Autoloader class
2018-01-25 23:13:53 +01:00
Nikita Popov
1cdb280a30
Merge branch '3.x'
2018-01-25 22:28:08 +01:00
Nikita Popov
d01fafcb40
Handle +(++$x) and -(--$x) as well
2018-01-25 22:27:37 +01:00
Nikita Popov
b85b6b3519
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/PrettyPrinter/Standard.php
2018-01-25 22:18:32 +01:00
Nikita Popov
94c715d97e
Fix pretty printing of -(-$x) and +(+$x)
...
Fixes #459 .
2018-01-25 22:17:35 +01:00
Nikita Popov
4dacbb8d39
FPPP: Fix indentation on list insertion
...
Use indentation of last list element, instead of indentation
before the insertion point.
Fixes #466 .
2018-01-25 22:08:40 +01:00
Gabriel Caruso
edafeb85c4
[CS] Order uses A -> Z
2018-01-13 16:08:27 +01:00
Gabriel Caruso
68d07c4662
[CS] New line in the end of file
2018-01-13 16:08:26 +01:00
Gabriel Caruso
8fae99aafe
[CS] Remove spaces
2018-01-13 16:08:25 +01:00
Nikita Popov
c7ada124d0
[CS] Use ::class notation instead of string
...
Conflicts:
test/PhpParser/ParserFactoryTest.php
test/PhpParser/ParserTest.php
2018-01-13 16:08:17 +01:00
Gabriel Caruso
e0a2043089
[CS] Space before casting
2018-01-13 16:03:57 +01:00
Gabriel Caruso
7f72c84122
[CS] Open class brackets in new line
2018-01-13 16:03:55 +01:00
Nikita Popov
5285df8f22
[CS] Use elseif instead of else if
...
Conflicts:
lib/PhpParser/TokenStream.php
2018-01-13 16:03:36 +01:00
Nikita Popov
92b39e3d1f
Fix nNextFreeElement for arrays with trailing comma
...
Ugh.
2017-12-26 21:17:36 +01:00
Nikita Popov
1c7fd314d1
FPPP: Add heuristic for multi-line lists
2017-12-26 21:14:36 +01:00
Nikita Popov
8d3cb5f57b
FPPP: Fallback if we must insert a block
2017-12-26 15:41:38 +01:00
Nikita Popov
de82a40d04
FPPP: Add broken InlineHTML test cases
2017-12-26 15:08:30 +01:00
Nikita Popov
a86151f24f
FPPP: Fix fallback for inline HTML
2017-12-26 15:08:29 +01:00
Gabriel Caruso
83b958763f
Refactoring tests
2017-12-15 21:42:34 +01:00
Gabriel Caruso
4dbb02c57b
Use Null Coalesce Operator
2017-12-15 21:41:41 +01:00
Nikita Popov
4fcdac40d1
FPPP: Fix insertion of multiple elems at start
2017-12-02 15:10:15 +01:00
Nikita Popov
04feb90d79
Rename abc1.test to basic.test
...
And split off fixup.test.
2017-12-01 23:15:50 +01:00
Nikita Popov
dc3ace55c3
FPPP: Support insert at start of list node ( #446 )
2017-12-01 22:09:51 +01:00
Nikita Popov
e5453f0d46
Extract pSingleQuotedString as an extension point
...
And add some more string formatting tests.
2017-12-01 18:31:21 +01:00
Nikita Popov
b507fa43da
Ensure names are not empty
2017-12-01 18:13:55 +01:00
Nikita Popov
336a49b428
FPPP: Fix comment indentation ( #443 )
2017-11-13 13:27:27 +01:00
Nikita Popov
4392a7b164
Fix PHP5 static call fixup
...
Variable nodes directly store the variable name as a string, they
don't use VarLikeIdentifier. So remove this wrapper if it exists.
2017-11-11 12:23:14 +01:00
Nikita Popov
457fe049a8
Ensure nodes have full complement of location info
2017-11-04 18:13:00 +01:00
Nikita Popov
6a2e1ae440
FPPP: Graceful handling of comment changes
2017-11-04 17:56:11 +01:00
Nikita Popov
47c973b3aa
Store start token position in comments
2017-11-04 17:45:14 +01:00
Nikita Popov
56bc8ebb9b
FPPP: Add support for removal from list nodes
2017-11-04 17:23:17 +01:00
Nikita Popov
fd6e8d7ea8
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Builder/Namespace_.php
lib/PhpParser/Node/Stmt/ClassMethod.php
test/PhpParser/Builder/NamespaceTest.php
2017-11-04 12:45:04 +01:00
Nikita Popov
0ba710affa
Add setDocComment() to namespace build ( #437 )
2017-11-04 12:43:02 +01:00
TomasVotruba
b58157f024
add strict_types to tests + fix explode type
2017-11-03 13:24:19 +01:00
Nikita Popov
b241a121a3
Fix trait alias to semi-reserved name parsing
...
This was missing the explicit construction of an Identifier node.
2017-10-29 14:15:48 +01:00
Nikita Popov
5900d78cc9
FPPP: Support anonymous classes ( #432 )
...
This is a huge hack... We temporarily create a new node with the
correct structure and use that for printing.
I think it would be better to always use a separate node type for
NewAnonClass, rather than using a combination of New and Class,
but this would require some larger changes, as this node type would
have to be both Expr and ClassLike, which is not possible right now,
as the latter is a class rather than an interface...
2017-10-29 12:26:12 +01:00
Nikita Popov
776275361a
FPPP: Support modifier changes ( #428 )
...
I decided against introducing a node type for this. In the end it
would require special handling anyway.
2017-10-25 22:27:29 +02:00
Nikita Popov
f5de7f9894
FPPP: Check that nodes are nodes in pArray()
2017-10-18 15:42:01 +02:00
Nikita Popov
bbec051e51
FPPP: Consolidate indentation levels
...
A bit annoying that we have to keep $this->nl always synchronized.
2017-10-06 18:21:08 +02:00
Nikita Popov
f071b66013
Print comments of inserted statements
2017-10-06 17:58:56 +02:00
Nikita Popov
57bc42517b
Move IdentifierTest where it belongs
...
Ooops...
2017-10-06 15:07:35 +02:00
Nikita Popov
bb2ac91115
Move leading space out of pStmt_Else
...
Same as previous commit. Also add support for pStmt_If->else
insertion.
2017-10-06 14:56:59 +02:00
Nikita Popov
310155832a
FPPP: Support insertion into list subnodes
...
With some rough edges...
2017-10-06 14:43:41 +02:00
Nikita Popov
ed8a744cd5
FPPP: Switch pArray() to use node list diffing
2017-10-06 12:02:00 +02:00
Nikita Popov
69aec6fb5b
Add implementation of Myers differ
...
Intended to be used in the format-preserving pretty printer for
handling changes in node lists.
2017-10-05 21:53:45 +02:00
Nikita Popov
65de924493
Add Identifier::toString()
...
For symmetry with the Name API.
Also add some missing unit tests.
2017-10-03 20:57:48 +02:00
Nikita Popov
f6cc85a796
FPPP: Fall back if comment in list node changes ( #420 )
2017-10-02 21:18:13 +02:00
Nikita Popov
cc600b67f6
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php5.php
lib/PhpParser/Parser/Php7.php
2017-10-01 16:55:54 +02:00
Nikita Popov
d418bf3951
Preserve comments on empty blocks ( #382 )
2017-10-01 16:54:43 +02:00
Nikita Popov
4b1d9667af
Add constant expression evaluator ( #402 )
2017-09-30 18:56:44 +02:00
Nikita Popov
cc328a4c9c
Add get{Start,End}{Line,TokenPos,FilePos}() methods
2017-09-29 17:34:15 +02:00
Nikita Popov
3d4621bbea
Don't return by ref from getAttribute()
...
This is not worth the few times where it might be useful.
2017-09-29 17:14:27 +02:00
Nikita Popov
d8f9173390
Add Node::getComments() method
2017-09-29 17:09:16 +02:00
Nikita Popov
df334eacaa
Add back commented test
...
We're not testing HHVM anymore, and I've already fixed this bug
upstream.
2017-09-26 18:47:47 +02:00
Nikita Popov
5cfdc2e0a7
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php5.php
lib/PhpParser/Parser/Php7.php
test/PhpParser/ParserTest.php
2017-09-26 18:46:44 +02:00
Nikita Popov
5a9fbca54a
Add attribute for namespace kinds ( #417 )
...
One of KIND_SEMICOLON or KIND_BRACED.
2017-09-26 18:45:05 +02:00
Nikita Popov
ec8692fb9e
Fix InlineHTML indentation
2017-09-03 19:02:07 +02:00
Nikita Popov
31065389f1
Remove workarounds for reserved keyword method names
...
No longer necessary in PHP 7.
2017-09-02 20:08:20 +02:00
Nikita Popov
efd39a67a2
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Builder/Trait_.php
test/PhpParser/Builder/TraitTest.php
2017-08-29 23:20:47 +02:00
Nikita Popov
d77e6cd6e9
Allow TraitUse statements in trait builder
...
Fixes #413 .
2017-08-29 23:18:59 +02:00
Nikita Popov
fa12dc8a22
Merge branch '3.x'
2017-08-29 23:15:04 +02:00
Nikita Popov
a10780ca0d
Handle Nop statement after brace-style namespace
...
Fixes #412 .
2017-08-29 23:14:27 +02:00
Nikita Popov
9373a8e9f5
Implement JsonDecoder
...
Converts JSON representation back into node tree.
2017-08-18 23:56:12 +02:00
TomasVotruba
af12807451
[cs] apply same to tests
2017-08-13 21:14:28 +02:00
Nikita Popov
46e7fea72d
Merge branch '3.x'
...
Conflicts:
test/PhpParser/Builder/ParamTest.php
2017-06-28 23:13:33 +02:00
Nikita Popov
4a7d011317
Add support for object type
2017-06-28 23:12:13 +02:00
Nikita Popov
4fea054ee0
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php7.php
2017-06-28 23:06:38 +02:00
Nikita Popov
7f862ac21c
Add support for trailing comma in group use
2017-06-28 23:05:28 +02:00
Nikita Popov
19dde1363e
Treat special names correctly in getShortName()
...
Also change the API to accept a string rather than a FullyQualified
name instance, as this is not appropriate for symbols like "self".
2017-06-13 19:51:22 +02:00
Nikita Popov
7646b31907
Merge branch '3.x'
2017-06-03 15:18:44 +02:00
Nikita Popov
bc0bff3f87
Fix method name in tests
2017-06-03 15:18:23 +02:00
Romain Neutron
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
Nikita Popov
73dc35cbbd
Allow null in ClassMethod::getStmts()
2017-05-07 19:56:14 +02:00
Wes
b1af3d1f7d
Add Node::setAttributes() ( #385 )
2017-05-05 18:18:44 +02:00
Nikita Popov
92275bdfa8
Remove Node::setLine() method
2017-04-29 13:01:02 +02:00
Nikita Popov
a32e3797d4
Generate PHP 7 type annotations
2017-04-28 21:40:59 +02:00
Nikita Popov
3da189769c
Distinguish between implicit/explicit alias
...
The UseUse::$alias node can now be null if an alias is not
explicitly given. As such "use Foo\Bar" and "use Foo\Bar as Bar"
are now represented differently.
The UseUse->getAlias() method replicates the previous semantics,
by returning "Bar" in both cases.
2017-04-28 21:05:01 +02:00
Nikita Popov
a6846e3b71
Always use Identifier nodes
...
The parser will now always generate Identifier nodes (for
non-namespaced identifiers). This obsoletes the useIdentifierNodes
parser option.
Node constructors still accepts strings and will implicitly create
an Identifier wrapper. Identifier implement __toString(), so that
outside of strict-mode many things continue to work without changes.
2017-04-28 20:57:32 +02:00
Nikita Popov
3b4abbfc97
Add BuilderFactors->args(Add BuilderFactors->args())
2017-04-28 18:13:06 +02:00
Nikita Popov
56b810e91d
Add getShortName() API
...
PHP's name resolution rules are f'ing complicated.
2017-04-28 17:10:30 +02:00
Ekin
3c44785e82
Bump phpunit version ( #381 )
2017-04-27 18:14:07 +02:00
Nikita Popov
8635365a30
Fix some typing issues
2017-04-26 21:50:40 +02:00
Nikita Popov
ceaed32e94
Fix typo in method name
2017-04-26 21:47:31 +02:00
Nikita Popov
5f7070e94f
Added BuilderFactory->concat() method
2017-04-24 21:42:59 +02:00
Nikita Popov
8f40eec122
Add BuilderFactory->val() method
2017-04-24 21:28:03 +02:00
Andreev Sergey
9dc93aafaa
Add ClassMethod::isMagic() method
2017-04-23 13:54:17 +02:00
Nikita Popov
55be521ff8
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Builder/Param.php
2017-04-19 11:17:52 +02:00
SignpostMarv
c877c1a64f
Add Builder\Param::makeVariadic()
2017-04-19 11:16:29 +02:00
Nikita Popov
bc75ac2990
Merge branch '3.x'
2017-04-09 19:51:18 +02:00
Nikita Popov
c3cbf07946
Pretty printer: Preserve comments in arrays and calls
...
If call arguments or array contains comments, print it in multiline
form, so that comments may be preserved.
2017-04-09 19:49:47 +02:00
Nikita Popov
1ec5591574
Tweak node insertion formatting
2017-04-08 23:11:46 +02:00
Tyson Andre
b5935a4aff
Fix a typo in NodeDumper for REQUIRE_ONCE ( #367 )
2017-03-17 11:35:48 +01:00
Nikita Popov
2beb4e7fd6
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/ParserAbstract.php
test/code/parser/errorHandling/recovery.test
2017-02-26 23:47:27 +01:00
Nikita Popov
d5873b177b
Adjust the end attributes on the stack as well
2017-02-26 23:45:14 +01:00
Nikita Popov
da97f78e25
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/ParserAbstract.php
test/code/parser/errorHandling/recovery.test
2017-02-26 23:40:32 +01:00
Nikita Popov
48ec654d0c
Make Expr\Error nodes empty
...
Resolves issue #359 .
2017-02-26 23:38:32 +01:00
Nikita Popov
f291a19fd5
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php7.php
2017-02-26 23:13:21 +01:00
Nikita Popov
c12a4c8239
Fix start attribute assignment for Error in ClassConstFetch
2017-02-26 23:00:38 +01:00
Nikita Popov
9f5ec5a69a
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Parser/Php5.php
lib/PhpParser/Parser/Php7.php
test/code/parser/stmt/class/name.test
2017-02-09 20:38:33 +01:00
Nikita Popov
df98b0417b
Handle "extends static" etc more gracefully
...
Use class_name production and emit the same error as for
"extends self" and "extends parent". It's weird that "extends
static" gives a different result than those two.
2017-02-09 18:43:09 +01:00
Nikita Popov
a8eb2fc675
Support recovery from invalid trailing commas
2017-02-09 00:35:12 +01:00
Nikita Popov
865bfb2acf
Merge branch '3.x'
...
Conflicts:
grammar/php7.y
lib/PhpParser/Parser/Php7.php
test/code/parser/expr/uvs/globalNonSimpleVarError.test
test/code/parser/stmt/namespace/groupUseErrors.test
2017-02-05 17:50:54 +01:00
Nikita Popov
62877b5d14
Recover from missing semicolons on statements
2017-02-05 17:47:56 +01:00
Nikita Popov
90b6d7cb5b
Remove XML serializer
2017-02-04 01:10:09 +01:00
Nikita Popov
987c61e935
Drop support for false return value in NodeTraverser
2017-02-03 22:36:57 +01:00