1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 04:14:44 +01:00
Commit Graph

33 Commits

Author SHA1 Message Date
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
Tomáš Votruba
d638dd9b25 Use methods instead of annotations for expected exceptions (#533) 2018-09-22 10:43:54 +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
Nikita Popov
5285df8f22 [CS] Use elseif instead of else if
Conflicts:
	lib/PhpParser/TokenStream.php
2018-01-13 16:03:36 +01:00
Gabriel Caruso
4dbb02c57b Use Null Coalesce Operator 2017-12-15 21:41:41 +01:00
TomasVotruba
b58157f024 add strict_types to tests + fix explode type 2017-11-03 13:24:19 +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
f071b66013 Print comments of inserted statements 2017-10-06 17:58:56 +02:00
TomasVotruba
af12807451 [cs] apply same to tests 2017-08-13 21:14:28 +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
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
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
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
1bfbd7bcc8 Make useExpressionStatement only supported mode 2017-01-19 21:15:26 +01:00
Nikita Popov
4d2a4d02b0 Add first shot at format preserving pretty printer 2016-12-26 18:28:49 +01:00
Nikita Popov
6bcc6c31dd Add useIdentifierNodes mode to parser
In this mode non-namespaced names that are currently represented
using strings will be represented using Identifier nodes instead.
Identifier nodes have a string $name subnode and coerce to string.

This allows preserving attributes and in particular location
information on identifiers.
2016-12-22 21:15:44 +01: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
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
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
9829bf69cd Fix issue #251 2016-02-28 20:28:32 +01: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
Nikita Popov
39a039fa42 Add option for short array syntax in pretty printer 2015-09-21 15:12:59 +08:00
Nikita Popov
d8312a09a3 Split parsing tests into code tests and other stuff
And run the other stuff against Php5 and Php7 parsers.

Also move canonicalize() from CodeTestAbstract into a free-standing
function.
2015-06-20 11:44:29 +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
f372a4c4ab Move modeline handling into CodeTestAbstract 2015-06-13 15:10:46 +02:00
Nikita Popov
1a627872f0 Rename nodes for compat with PHP 7
The old names will still be available on PHP 5.x.
2015-03-20 21:49:38 +01:00
Nikita Popov
6930feac43 Add some tests for pretty printing expressions 2015-01-18 19:57:09 +01:00
nikic
66fd29cb58 Use stricter assertions where possible 2014-09-30 20:38:09 +02:00
nikic
6dc24fa9f5 Fix coverage annotations 2014-09-28 12:49:12 +02:00
nikic
f82862ec9c Port library to use namespaces, with BC for old names 2014-02-06 20:29:35 +01:00