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
Nikita Popov
2b72bae3d9
Throw if NodeVisitor returns invalid value
2017-02-03 22:30:26 +01:00
Nikita Popov
2b6804aa50
Throw on nested array in NodeTraverser
...
The AST never uses deeply nested arrays, so don't support this in
the node traverser. Throw an exception instead.
2017-02-03 22:11:31 +01:00
Nikita Popov
d9911c8da5
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/Node/Expr/ClassConstFetch.php
test/PhpParser/PrettyPrinterTest.php
2017-02-03 21:54:48 +01:00
Nikita Popov
d287c167bc
Pretty print: Handle Error in ClassConstFetch
2017-02-03 21:53:02 +01:00
Nikita Popov
79afd56565
Add NodeFinder class
...
To simplify basic node finding operations.
2017-01-29 23:20:53 +01:00
Nikita Popov
5cc2750ebc
Merge branch '3.x'
...
Conflicts:
lib/PhpParser/NodeVisitor.php
2017-01-29 22:36:33 +01:00
Nikita Popov
58e7881e98
Implement NodeTraverser::STOP_TRAVERSAL
...
Conflicts:
lib/PhpParser/NodeVisitor.php
2017-01-29 22:35:40 +01:00
Nikita Popov
e072c789d1
Merge branch '3.x'
...
Conflicts:
test/PhpParser/PrettyPrinterTest.php
2017-01-29 21:57:37 +01:00
Nikita Popov
fd7ac25108
Throw if pretty-printing Error node
2017-01-29 21:56:21 +01:00
Nikita Popov
bfea338d36
Update doc comments after previous comment
...
Make some of the type annotations more accurate, and complete the
generated doc-comments to be complete (with description and
parameter annotations.)
2017-01-26 00:16:54 +01:00
Nikita Popov
cb5dd28985
Don't include whitespace directly in catch/finally print
2017-01-21 21:25:48 +01:00
Nikita Popov
5e565e8046
Support insertion of nullable nodes
...
Still incomplete in some places and the formatting is not always
ideal.
2017-01-21 21:20:42 +01:00
Nikita Popov
b9b6aeeed9
Support format-preserving node removal
...
Take care of stripping surrouding tokens appropriately.
2017-01-21 17:52:50 +01:00
Nikita Popov
0607450f78
Add FinderVisitor
...
Allows finding nodes based on a filter callback.
2017-01-21 15:41:24 +01:00
Nikita Popov
b5fb6f2d0a
Don't require useNopStatements=false for format preservation
...
Instead assign attributes on Nop nodes and in the pretty printer
specially handle end<start offsets. It's a somewhat weird case,
but not wrong per se given the meaning the offsets have.
2017-01-20 22:27:51 +01:00
Nikita Popov
48d3243abe
Drop last vestiges of consistent var mode flag
2017-01-19 23:46:25 +01:00
Nikita Popov
d7f3c4f9d3
Renamve Param::$name to Param::$var
...
As it now contains a Variable node.
2017-01-19 23:39:15 +01:00
Nikita Popov
a79306ccd9
Rename StaticVar::$name to $var
...
As it now holds a Variable
2017-01-19 23:35:31 +01:00
Nikita Popov
6238f5f9f9
Adjust code for constitent var mode
2017-01-19 23:32:49 +01:00
Nikita Popov
67274b9594
Enforce useConsistentVariableNames
2017-01-19 23:24:43 +01:00
Nikita Popov
7623d20f69
Automatically wrap in Stmt\Expression in builders
2017-01-19 22:39:21 +01:00
Nikita Popov
33552764ad
Perform manual test updates
2017-01-19 22:31:29 +01:00