Nikita Popov
818ef2e692
Make PrettyPrinter\Standard methods protected
...
I'm not sure how these ever ended up being public.
2016-07-25 14:27:03 +02:00
Nikita Popov
5f97b12576
Introduce explicit Finally node
2016-07-25 14:25:04 +02:00
Nikita Popov
1dea9111a2
NodeDumper: Resolve type for include/use as well
2016-07-25 14:04:04 +02:00
Nikita Popov
174e6c3cab
NodeDumper: Print modifiers as strings
2016-07-25 13:53:49 +02:00
Nikita Popov
18129480ae
Rename $type subnode to $flags
...
Type makes it sound like a type-hint, and on a number of other nodes
$type is used for exactly that. Use $flags to hold modifiers instead.
2016-07-25 13:33:19 +02:00
Nikita Popov
867ae5148d
Bring Trait constructor in line with Class/interface
2016-07-22 17:01:51 +02:00
Nikita Popov
537b59d4d1
PHP 7.1: Support multi-catch
...
Catch::$type is now an array Catch::$types.
2016-07-22 15:40:00 +02:00
Nikita Popov
7ff12b8fcb
Remove deprecated Comment methods
2016-07-09 22:00:39 +02:00
Nikita Popov
574665b45b
PHP 7.1: list() with keys
...
Expr\List will now contain ArrayItems instead of plain variables.
I'm reusing ArrayItem, because code handling list() must also handle
arrays, and this allows both to go through the same code path.
This also renames Expr\List->vars to ->items.
TODO: Should Expr\List be dropped in favor of Expr\Array with an
extra flag?
2016-07-09 21:55:55 +02:00
Nikita Popov
437890d386
PHP 7: Short destructuring syntax
...
Potentially the pretty printer should force use of [] in assignment
context, instead of relying on the existance of the right attribute.
2016-07-06 23:43:23 +02:00
Nikita Popov
1edf72c040
PHP 7: Support nullable types
...
Using a new NullableType node.
2016-07-06 18:36:18 +02:00
Nikita Popov
7a54aca468
Merge branch '2.x'
2016-07-06 02:21:57 +02:00
Nikita Popov
81f7da3b23
Fix computation of expected tokens in parse errors
2016-07-06 02:21:48 +02:00
Nikita Popov
5ea2a76d80
PHP 7.1: Class constant visibility support
2016-07-05 23:01:06 +02:00
Nikita Popov
5044fce1ff
PHP 7.1: Add void+iterable support
...
In PHP 7 mode, these will now be represented as strings 'void'
and 'iterable'.
2016-07-05 22:35:27 +02:00
Nikita Popov
038e11da4b
Remove support for PHP 5.4
2016-07-05 22:29:41 +02:00
Nikita Popov
96cbd48df6
Improve error recovery quality
...
In particular, support recovering from a missing trailing semicolon,
while keeping the rest of the expression.
2016-04-20 16:47:50 +02:00
algo13
371c783344
Escape all low control characters in strings
2016-04-19 17:45:39 +02:00
Nikita Popov
5a6e7dd452
Avoid superfluous newline when printing Nops
2016-04-19 15:10:51 +02:00
Nikita Popov
90eb1165d1
Switch Exit kind attribute to flag
...
To be consistent with everything else.
2016-04-19 14:51:05 +02:00
Nikita Popov
e7869b9f14
Forbid invalid octals in PHP 7 mode
2016-04-18 13:59:18 +02:00
Nikita Popov
4c7ad7e194
Allow nop statements before namespace declaration
2016-04-16 21:39:49 +02:00
Remi Collet
f8a40b3f24
Make autoloader more PSR-4 ( #268 )
2016-04-15 15:07:30 +02:00
Graham Campbell
e7f0860d85
Tweaked a phpdoc description
2016-04-10 21:10:55 +09:00
lvht
39f93f09f9
Add setReturnType() method to function/method builders
...
Also support scalar type hints in existing setTypeHint() method on params.
2016-04-09 18:41:38 +09:00
Nikita Popov
588e6a4d4c
Add string kinds and doc string labels
...
Scalar\String_ and Scalar\Encapsed now have an additional "kind"
attribute, which may be one of:
* String_::KIND_SINGLE_QUOTED
* String_::KIND_DOUBLE_QUOTED
* String_::KIND_NOWDOC
* String_::KIND_HEREDOC
Additionally, if the string kind is one of the latter two, an
attribute "docLabel" is provided, which contains the doc string
label (STR in <<<STR) that was originally used.
The pretty printer will try to take the original kind of the string,
as well as the used doc string label into account.
2016-04-07 12:09:00 +09:00
Nikita Popov
52cb5ecec7
Fix comment reformatting for some cases
...
It did not correctly deal with non-standard comments containing
indented lines.
2016-04-07 11:47:40 +09:00
Nikita Popov
14de71898e
Fix nop statement comment assignment
...
Keep around the start attributes on the lookahead token around in
a separate parser property.
2016-04-05 19:19:15 +09:00
Nikita Popov
b31a973fa7
Another fix for B"" handling
...
The lexer fix also need to account for uppercase B.
2016-04-04 22:07:50 +09:00
Nikita Popov
9ac3592190
Handle uppercase B"" prefix
2016-04-02 21:15:49 +09:00
Nikita Popov
35011d2e4d
Deduplicate attribute assignment code a bit
2016-04-02 08:02:58 +09:00
Nikita Popov
60f01bdd86
Deprecate setters on Comment
...
No point in making it mutable
2016-04-02 07:55:28 +09:00
Nikita Popov
15a2388d75
Add start file offset to Comments
2016-04-02 07:54:01 +09:00
Nikita Popov
eb4bfe1366
Add sanity check for leaveNode() return value
2016-03-27 14:52:15 +02:00
Nikita Popov
fc36239be5
Remove internal LNumber::parse() method
...
Combine it into ::fromString(), as they both do the same checks.
2016-03-10 13:01:42 +01:00
Nikita Popov
f493219c7d
Move "kind" attribute handling out of lexer
...
Doesn't belong there and will cause issue with multiple assignments.
2016-03-10 12:55:15 +01:00
Nikita Popov
aa199120c7
Add kind attribute for arrays
...
To distinguish array() and [] syntax. The pretty printer respects
this attribute. The shortArraySyntax pretty printer option acts as
a default in case the attribute is not specified.
2016-03-09 21:31:54 +01:00
Nikita Popov
ae30f97af6
Add "kind" attribute to LNumbers
...
Kind specifies whether the number was formatted as decimal, octal,
binary or hex. The pretty printer reproduces the number kind (but
not necessarily the exact formatting).
2016-03-09 21:10:55 +01:00
Nikita Popov
47c342a3e4
Add "kind" attribute to Stmt\Exit_
...
Attribute specifies whether this is a "die" or an "exit" and the
pretty printer behaves accordingly.
2016-03-09 20:20:36 +01:00
Nikita Popov
7eac2cfd8b
Introduce Nop statement to collect dangling comments
...
A Nop statement will be inserted into statement lists if there are
any trailing comments in the list (which would otherwise not be
associated with any node).
The pretty printer output currently still contains a superfluous
newline.
2016-03-09 19:48:36 +01:00
Nikita Popov
a0c216bf4b
Add dumpComments option to NodeDumper
...
Adding this as an option to avoid breaking people's tests.
Some of the test results show pretty clearly that we are incorrectly
assigning the same comment multiple times for nested nodes (mentioned
in #36 ).
2016-03-09 19:48:36 +01:00
Nikita Popov
9829bf69cd
Fix issue #251
2016-02-28 20:28:32 +01:00
Nikita Popov
1fe8f09caa
Fix __halt_compiler() pretty printing edge case
...
We can't strip the <?php at the end of a __halt_compiler() segment
in file mode.
Fixed by being a bit more explicit in prettyPrintFile() about what
we want to do...
2016-02-20 18:24:32 +01:00
Nikita Popov
65af37f7b0
Doc comment tweaks
2016-02-20 17:06:09 +01:00
Nikita Popov
d6361136e1
Update semi-reserved keyword list
...
Magic constant names have been added after the PHP 7 release.
We do not support and likely will not support __halt_compiler here
due to lexer limitations.
2016-02-09 13:30:39 +01:00
Nikita Popov
6dffb72ce0
Merge branch '1.x'
2016-01-15 22:02:35 +01:00
Nikita Popov
eb73441032
Support hashbang before namespace declaration
...
Fixes issue #243 .
2016-01-15 22:01:51 +01:00
Jesse Schalken
5c2cc50455
Remove some more unecessary @property doc comments
2015-12-29 23:15:00 +11:00
Jesse Schalken
58eb1ea7c3
Remove some unecessary @property doc comments
2015-12-29 23:13:55 +11:00
Nikita Popov
719ca71d4a
Distinguish declare(); and declare(){}
...
It makes semantic difference and the latter form is actually
forbidden for strict_types.
This sets Declare->stmts to null for the body-less case.
2015-12-07 12:12:00 +01:00