Nikita Popov
ec8692fb9e
Fix InlineHTML indentation
2017-09-03 19:02:07 +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
58970e2a37
Improve LNumber/DNumber pretty printing
...
* Support PHP_INT_MIN
* Support negative binary/octal/hex numbers
* Support INF/-INF/NAN in namespaces
2016-12-11 16:31:59 +01:00
Nikita Popov
5219f75719
Fix pretty-printing of nullable types
2016-12-06 12:26:21 +01:00
Nikita Popov
ec614c95dd
Add hasLeadingNewline attribute to InlineHTML
...
Use this attribute to not print an extra newline if the original
code did not have it.
2016-07-25 16:44:25 +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
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
5ea2a76d80
PHP 7.1: Class constant visibility support
2016-07-05 23:01:06 +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
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
5fa8493675
Make canonicalization less aggressive
2016-04-05 10:37:45 +09: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
a73aa7eec1
Pretty printer test coverage
...
Our output for yield / yield from is currently not very nice, but
also not easy to change.
2016-02-20 21:49:21 +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
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
Nikita Popov
98d28d7aa0
Drop test failing on HHVM
...
Can readd if Travis ever updates the HHVM version again, I
remember this being fixed ages ago.
2015-10-03 12:17:41 +02:00
Nikita Popov
e4b837e0c4
Split up pretty printer test in stmt/expr
...
The list was getting unweildly.
Also improve error message when parsing fails in pretty printer
test and extend some tests.
2015-10-02 11:16:12 +02:00
Aydin
99e89743bd
More PrettyPrinter tests
2015-10-02 11:03:32 +02:00
Nikita Popov
39a039fa42
Add option for short array syntax in pretty printer
2015-09-21 15:12:59 +08:00
Nikita Popov
8090531acd
Fix pretty printing of const derefs for 5.x
...
(FOO)[0] is only supported on 7.x
2015-07-09 12:38:30 +02:00
Nikita Popov
71fa7c6674
Support UVS in pretty printer
...
Try to generate interoperable code where possible (but not
everything can be expressed in PHP 5).
2015-06-13 20:01:01 +02:00
Nikita Popov
1a1bd1448d
Support mixed group use declarations
2015-06-13 11:27:38 +02:00
Nikita Popov
9620f79cdc
Add partial group use support
...
Supported via Stmt\GroupUse which has Name $prefix in addition to
the usual.
Still missing: Mixed group uses.
2015-06-12 23:05:28 +02:00
Nikita Popov
8b64195cf2
Try .17G print if .16G is not enough
...
This should be enough for all cases, because: A double has 53 bits
of mantissa (including the implicit 1 bit), which is 53*ln(2)/ln(10)
= 15.95 decimal digits. However the leading decimal digit may encode
less than the usual 3.32 bits, which will push this over the edge to
requiring 17 decimal digits.
2015-05-02 11:48:55 +02:00
Nikita Popov
648800f07f
Increase float pretty printing precision
...
This removes the reliance on the "precision" ini setting.
Furthermore the default of precision=14 is not sufficient.
2015-05-01 19:15:33 +02:00
Nikita Popov
e1a0ec3724
Add support for anonymous classes
...
Has not landed upstream yet, but syntax is unlikely to change.
2015-04-26 23:04:31 +02:00
Nikita Popov
338bc1f8e7
Fix "print" pretty-printing
...
Precedence was previously ignored.
2015-04-26 11:56:04 +02:00
Nikita Popov
ab80054e97
Add support for "yield from"
2015-04-26 11:56:02 +02:00
Nikita Popov
251e689283
Add support for spaceship operator (<=>) [PHP 7]
...
Added as Expr\BinaryOp\Spaceship.
2015-03-12 23:13:31 +01:00
Nikita Popov
01f4be6b4d
Add support for null coalesce operator (??) [PHP 7]
...
Added as Expr\BinaryOp\Coalesce.
2015-03-12 22:45:56 +01:00
Nikita Popov
dc28449d81
Drop whitespace after ... varargs collection
...
Also drop an obsolete pretty printer test.
2015-03-12 22:19:34 +01:00
Nikita Popov
3ad0d4b310
Add support for return type declarations [PHP 7]
...
This adds an additional "returnType" subnode to Stmt\Function_,
Stmt\ClassMethod and Expr\Closure, as well as the corresponding
support in the name resolver and pretty printer.
2015-03-12 22:16:12 +01:00
Nikita Popov
4dbf067b4b
Add a few more string interpolation tests
...
Originally wanted to simplify the pretty-printer output, but ...
edge cases everywhere :/
2015-03-11 20:01:26 +01:00
Thomas Ruiz
73cace360d
Implicit public should not generate as explicit public
2015-03-08 20:21:01 +01:00
Nikita Popov
6930feac43
Add some tests for pretty printing expressions
2015-01-18 19:57:09 +01:00
nikic
7fbdb79a08
Fix whitespace when printing trait alias modifiers
2014-11-03 16:16:15 +01:00
nikic
91f6880734
Improve pretty printing of empty statement lists
...
The pStmts() method now also includes the leading \n, however only
if the statement list is non-empty.
2014-03-27 12:31:21 +01:00
nikic
3b7829b011
Add support for function and constant import (PHP 5.6)
2014-03-26 22:33:45 +01:00
nikic
cda6f575f0
Add support for pow operator (PHP 5.6)
2014-03-26 19:18:16 +01:00
nikic
b5bcfa1168
Add support for argument unpacking (PHP 5.6)
2014-03-26 18:42:46 +01:00
nikic
96f1151ab2
Add support for variadic parameters (PHP 5.6)
2014-03-26 18:23:30 +01:00
Tomáš Polomský
c8c233f900
Correctly pretty print negative floats
2014-03-22 14:24:35 +01:00
nikic
77c08a75c9
Fix pretty printing of include
expressions
2013-07-27 16:23:27 +02:00
nikic
08f0cde6f9
Add prettyPrintFile() method
2013-04-15 20:53:23 +02:00
nikic
81d20bf10e
Pretty print namespaces in semicolon-style if possible
2013-01-15 18:21:42 +01:00