Dmitry Patsura
e3a9356178
Use composer PSR-4 autoloader
2015-09-16 22:02:00 +09:00
Nikita Popov
fe6755ff4c
Use more helpful code test names
2015-08-25 21:36:08 +02:00
Nikita Popov
f57d217e91
Update group use support
...
To conform with current PHP 7 implementation
* Allow use \Foo\{Bar};
* Disallow use Foo\{\Bar};
* Disallow missing trailing semicolon (that was a bug)
2015-08-20 16:42:49 +02:00
Nikita Popov
dc85742034
Merge branch '1.x'
...
Conflicts:
CHANGELOG.md
composer.json
test/PhpParser/ParserTest.php
2015-07-14 19:43:49 +02:00
Nikita Popov
b9afcdfd92
Revert "Make tests compatible with PHP 7"
...
This reverts commit 91295a0790
.
This should no longer be necessary.
Conflicts:
test/PhpParser/ParserTest.php
2015-07-14 19:21:57 +02:00
Nikita Popov
feb82eed33
Disable cloning in traverser by default
2015-07-14 17:39:56 +02:00
Nikita Popov
0ef15c111a
Merge branch '1.x'
2015-07-14 17:08:28 +02:00
Nikita Popov
d341d94976
Add ClassLike::getMethod($name)
...
To allow getting individual method with a given name.
2015-07-14 17:07:45 +02:00
Nikita Popov
0265c28e6e
Switch NameResolver resolve methods to be immutable
...
To make it theoretically possible to expose this as API.
Add slice() method to Name to allow this. Deprecate existing mutable
Name APIs.
2015-07-12 23:56:57 +02:00
Nikita Popov
5bd8cb84de
Add dummy ParserFactory test
...
:/
2015-07-12 22:53:17 +02:00
Nikita Popov
ebeeae19a6
Merge branch '1.x'
2015-07-12 22:12:28 +02:00
Nikita Popov
5ede167835
Fix infinite recursion in Use builder __call
2015-07-12 22:11:43 +02:00
Nikita Popov
21e51c8cf6
Add some tests for Multiple parser
2015-07-12 22:00:02 +02:00
Nikita Popov
e7a2abb03b
Merge branch '1.x'
2015-07-11 22:33:19 +02:00
Nikita Popov
b862de1f5b
Support properties in trait builder
2015-07-11 22:31:45 +02: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
1d62e9d8cc
Fix implicit visibility for properties as well
...
Also switch to using PPP mask.
2015-07-05 20:17:52 +02:00
Lisachenko Alexander
2a3bc608dc
Add broken test for implicit public nodes
2015-07-05 20:17:49 +02:00
Nikita Popov
90ab32f046
Merge branch '1.x'
2015-07-05 20:16:41 +02:00
Nikita Popov
7434a682e5
Fix implicit visibility for properties as well
...
Also switch to using PPP mask.
2015-07-05 20:16:21 +02:00
Lisachenko Alexander
5e6627c895
Add broken test for implicit public nodes
2015-07-05 20:10:47 +02:00
Nikita Popov
f872fa9b0b
Merge branch '1.x'
2015-07-04 14:40:53 +02:00
Nikita Popov
d5668f536d
Fix __HALT_COMPILER_OFFSET__ support on HHVM
2015-07-04 13:15:48 +02:00
Nikita Popov
9c9a8cddce
Merge branch '1.x'
2015-06-20 12:34:36 +02:00
Nikita Popov
fd7ee2e083
Add missing regex anchor
2015-06-20 12:34:10 +02:00
Nikita Popov
f2b7a31509
Rename ParserInterface to Parser
...
And drop the alias of Parser to Parser\Php5.
2015-06-20 11:47:25 +02: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
ef9a154d09
Add support for unicode escape sequences
...
Only parsed if the PHP 7 parser is used.
2015-06-13 20:51:02 +02:00
Nikita Popov
0da72fad00
Support scalar type declarations
2015-06-13 20:16:09 +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
f3f24e03ae
Support running against PHP 7 testsuite
2015-06-13 19:09:24 +02:00
Nikita Popov
bc21514ecf
Move token constants into separate class
...
As these are shared between Php5 and Php7 parsers they should be
in some common place, otherwise we'd have to always reference either
one or the other.
2015-06-13 18:39:55 +02:00
Nikita Popov
04e05907c3
Fix CRLF issue in Serializer\XML test
...
No idea why this suddenly turned up now.
2015-06-13 18:20:05 +02:00
Nikita Popov
61e060694d
Implement generalized yield operator
...
And split tokens.y off, so I don't waste time debugging this again...
2015-06-13 18:11:40 +02:00
Nikita Popov
602b9807eb
Import some UVS tests
2015-06-13 15:42:09 +02:00
Nikita Popov
f372a4c4ab
Move modeline handling into CodeTestAbstract
2015-06-13 15:10:46 +02:00
Nikita Popov
d18dcc0c7f
Implement UVS
2015-06-13 14:59:24 +02:00
Nikita Popov
74c57eef0e
Test PHP 5 and PHP 7 parsers
...
At this point they should return the same result.
2015-06-13 13:56:45 +02:00
Nikita Popov
dca46febc9
Implement semi-reserved identifiers
2015-06-13 12:47:13 +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
5d1e3be7d4
Anonymize some callbacks
2015-05-02 22:35:15 +02:00
Nikita Popov
cc75dd3612
Drop support for PHP 7 aliases
2015-05-02 22:21:12 +02:00
Nikita Popov
5f621c5adc
Drop support for legacy aliases from v0.9
2015-05-02 22:19:25 +02:00
Nikita Popov
29b9015f51
Drop support for old Node format
2015-05-02 22:17:34 +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
9caa51b3a5
Add some more tests
2015-05-01 20:18:04 +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
23bf4f0c13
Add some error documentation
2015-04-30 21:58:45 +02:00
Nikita Popov
272ab6c8d8
Add some recovery tests
2015-04-30 19:02:51 +02:00
Nikita Popov
0731b47655
Don't distinguish test-fail / test
...
With error recovery this is fluid. Using .test for everything.
2015-04-30 17:45:36 +02:00
Nikita Popov
3b7d8e8b5d
Enable basic error recovery
...
Adding only a single recovery rule for now.
The API is now:
* throwOnError parser option must be disabled.
* List of Errors is available through $parser->getErrors(). This
method is available either way.
* If no recovery is possible $parser->parse() will return null.
(Obviously only if throwOnError is disabled).
2015-04-30 17:41:57 +02:00
Nikita Popov
a35c2a2067
Add column info to EOF errors
...
EOF errors are now located one past the end of the file.
2015-04-27 15:37:41 +02:00
Nikita Popov
55b2ead967
Make special class name checks case insensitive
2015-04-26 23:13:27 +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
c8454271e1
Make column info 1-based
2015-04-18 21:20:45 +02:00
Nikita Popov
62f83a0dc2
Add column info for non-syntax errors where relatively precise
...
Should it also be added if only rough information is available? E.g.
spanning an entire class?
2015-04-18 13:27:58 +02:00
Nikita Popov
611fa5c7f1
Test parser position information (syntax errors)
2015-04-18 13:27:57 +02:00
Nikita Popov
4defbc2174
Make Error column info attribute based
2015-04-18 12:51:26 +02:00
Gerrit Addiks
33a39fae06
added column-numbers to syntax errors
2015-04-18 10:14:49 +02:00
Nikita Popov
617bf0aa41
Fix registering of PHP 7 aliases
...
The previous approach was causing issues, because "instanceof"
does not invoke the autoloader.
2015-03-24 20:04:50 +01:00
Nikita Popov
dce19b074b
Strict type compliance
...
Were this library to be fully annotated with scalar types and
return types where possible and were strict types to be enabled
for all files, the test suite would now pass.
2015-03-24 11:19:17 +01:00
Matthieu Napoli
729c7bde0c
#184 Add a flag to NodeTraverser to avoid cloning nodes
2015-03-22 11:19:04 +13:00
Nikita Popov
8982315b4e
Rename Cast\Object as well
...
As it will very likely be soft-reserved in PHP 7.
Old alias is still available, as usual.
2015-03-21 18:57:55 +01:00
Nikita Popov
7ec277e1e1
Replace another Scalar\String occurance
...
Also canonicalize NameResover tests to avoid those pesky CRLF
issues.
2015-03-21 18:47:20 +01: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
592836c4dc
Add support for T_HASHBANG (HHVM)
2015-03-14 19:53:08 +01: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
Nikita Popov
0c34706799
Add "use" builder
2015-03-10 16:05:55 +01:00
Nikita Popov
f9fc2fc9ee
Add support for global namespace in NS builder
...
NULL argument can now be used to create a global namespace {} block.
2015-03-10 15:28:19 +01:00
Nikita Popov
a2d7e8977a
Use real properties for storing subnodes
...
Instead of storing subnodes in a subNodes dictionary, they are
now stored as simple properties. This requires declarating the
properties, assigning them in the constructor, overriding
the getSubNodeNames() method and passing NULL to the first argument
of the NodeAbstract constructor.
[Deprecated: It's still possible to use the old mode of operation
for custom nodes by passing an array of subnodes to the constructor.]
The only behavior difference this should cause is that getSubNodeNames()
will always return the original subnode names and skip any additional
properties that were dynamically added. E.g. this means that the
"namespacedName" node added by the NameResolver visitor is not treated
as a subnode, but as a dynamic property instead.
This change improves performance and memory usage.
2015-03-09 08:54:20 +01:00
Thomas Ruiz
73cace360d
Implicit public should not generate as explicit public
2015-03-08 20:21:01 +01:00
Nikita Popov
d56ff5a351
Fix lexer tests for HHVM
...
HHVM does not throw warnings from token_get_all()
for invalid chars and unterminated comments. This
is not really integral functionality, so I'm okay
to just skip it to get a passing HHVM build.
2015-02-26 19:19:40 +01:00
Nikita Popov
3028bc8081
And make it work on PHP 5 as well...
2015-02-26 16:40:21 +01:00
Nikita Popov
91295a0790
Make tests compatible with PHP 7
...
When parsing on PHP 7 we will no longer be able to deal with
code that contains invalid octal literals. Currently we'll fatal,
after engine exceptions land we'll throw an exception instead.
2015-02-26 16:26:29 +01:00
Tom Rochette
1366e833a1
Move getMethods() to new ClassLike node
...
Class_, Interface_ and Trait_ extend the ClassLike node, which
provides the getMethods() method.
2015-01-31 22:59:38 +01:00
Nikita Popov
6930feac43
Add some tests for pretty printing expressions
2015-01-18 19:57:09 +01:00
Nikita Popov
0a445c7656
Test lexer returning invalid token
2015-01-18 00:11:10 +01:00
Nikita Popov
9689763e20
Cover both DONT_TRAVERSE_CHILDREN cases
2015-01-18 00:10:01 +01:00
Nikita Popov
4071c4645d
Add NodeTraverser::DONT_TRAVERSE_CHILDREN support
2015-01-11 22:13:58 +01:00
Nikita Popov
4cd2b95a23
Fix 5.3 build and some small cleanups
2014-12-19 18:54:56 +01:00
Nikita Popov
7ab88416ac
Enforce Name|string for names in builders
...
While array (with name components) could technically be allowed (as
they are supported by the Name node itself), more likely than not
an array would due to incorrect usage of the API (e.g. array instead
of variadics).
2014-12-19 18:50:16 +01:00
Nikita Popov
ba625063e7
Support fully-qualified and ns-relative names in builders
2014-12-19 18:48:21 +01:00
Nikita Popov
b4b93ccb21
Add integration test for builders
2014-12-19 18:35:19 +01:00
Stepan Anchugov
01643e06d3
Add namespace builder
2014-12-19 18:19:33 +01:00
Nikita Popov
4387454fe0
Add trait builder (for completeness...)
2014-12-19 17:59:23 +01:00
Nikita Popov
e69c9ee38c
Fix attribute assigment test with crlf newlines
2014-12-19 17:28:22 +01:00
Nikita Popov
894c3f787d
Add test for attribute assignment by parser
...
Weird that this wasn't tested yet...
2014-12-19 00:37:38 +01:00
Nikita Popov
46975107a7
Support token position attributes in lexer
...
Also change endFilePos semantics to refer to the last character that
is *included* in the token, rather than one past the last character.
This ensures that all end* attributes have the same semantics.
2014-12-19 00:37:36 +01:00
Nikita Popov
2438848487
Add support for doc comments in builders
2014-12-13 13:44:40 +01:00
nikic
8507af6f4a
Add missing require in tests
...
Test files aren't autoloaded, so this was order-dependent.
2014-11-27 21:01:56 +01:00
nikic
7c98ad6f9b
Support file offsets in emulative lexer as well
...
Also run normal lexer tests against emulative lexer and fix a bug
in __halt_compiler() handling found as a result.
2014-11-27 20:57:38 +01:00
Máximo Cuadros Ortiz
d774dbc1b7
Add optional startFilePos and endFilePos attributes
...
The lexer can now optionally add startFilePos and endFilePos
attributes, which are offsets in to the lexed code string.
The end offset currently points one past the last character of
the token - this is pending further discussion.
The attributes are not added by default and have to be enabled
using the new 'usedAttributes' lexer option:
$lexer = new Lexer([
'usedAttributes' => [
'comments', 'startLine', 'endLine',
'startFilePos', 'endFilePos'
]
]);
2014-11-27 20:38:29 +01:00
nikic
e26e63e9b0
Error on final or abstract properties
2014-11-13 20:25:52 +01:00