Commit Graph

79 Commits

Author SHA1 Message Date
Nikita Popov
91cb82d3d2 Explicitly support Name copy construction
It already worked beforehand by accident ... make clear it's
actually supported.
2016-10-22 16:41:58 +02:00
Nikita Popov
7672b974ff Remove Name::append() and Name::prepend() 2016-10-22 00:25:15 +02:00
Matthew Brown
623bad2c8b Type encapsulated string parts specifically 2016-10-21 11:46:54 +02:00
Matthew Brown
f66cf8f0dd $name can be null for PHP 7 anonymous classes 2016-10-21 11:46:14 +02:00
Nikita Popov
a910f6a247 Remove $separator arg from Name::toString() 2016-10-09 12:45:15 +02:00
Nikita Popov
caa5c0cc76 Graceful handling for "special" errors
Nearly all special errors are now handled gracefully, i.e. the
parser will be able to continue after encountering them. In some
cases the associated error range has been improved using the new
end attribute stack.

To achieve this the error handling code has been moved out of the
node constructors and into special methods in the parser.
2016-10-09 12:38:18 +02:00
Nikita Popov
1ab24d26ee Add support for PHP 7.1 types to builders
This adds support for void, iterable and nullable types.
2016-09-16 13:53:13 +02:00
Nikita Popov
09086fbe0a Support partial parsing of $foo->
Introduce Error node for this purpose.
2016-07-25 17:03:58 +02:00
Nikita Popov
b740076ab1 Remove deprecated Name::set*() methods 2016-07-25 14:50:37 +02:00
Nikita Popov
c9fea2ef67 Extend Name::slice() to support negative length+offset 2016-07-25 14:47:24 +02:00
Nikita Popov
5f97b12576 Introduce explicit Finally node 2016-07-25 14:25:04 +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
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
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
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
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
9ac3592190 Handle uppercase B"" prefix 2016-04-02 21:15:49 +09: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
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
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
Nikita Popov
a9074c7444 Introduce Scalar\EncapsedStringPart 2015-12-03 22:55:07 +01:00
Nikita Popov
eecaf1e93b Merge branch '1.x'
Conflicts:
	grammar/rebuildParsers.php
	lib/PhpParser/Parser.php
2015-09-19 22:07:29 +08:00
Nikita Popov
950ada4cba Fix issue #227
Use \z instead of $.
2015-09-19 22:05:23 +08: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
49324ea412 Drop default values from Scalar ctor params 2015-07-12 22:02:18 +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
e3195c246f Fix public modifier check for ClassMethod node 2015-07-05 20:17:50 +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
0fbb5f90a1 Fix public modifier check for ClassMethod node 2015-07-05 20:10:48 +02:00
Nikita Popov
a5db176903 Merge branch '1.x' 2015-07-02 18:09:38 +02:00
Nikita Popov
42e368e964 Fix returnType typehints
Fixes issues #207
2015-07-02 18:06:41 +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
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
db3dafd64d Merge branch '1.x' 2015-06-05 18:57:04 +02:00
Suralc
bb2c5303ae Add a FunctionLike interface to Methods, Functions and Closures.
The elements listed above share common elements like parameters, possible return types and bodies.
2015-06-05 18:56:25 +02:00
Nikita Popov
5d1e3be7d4 Anonymize some callbacks 2015-05-02 22:35:15 +02:00
Nikita Popov
29b9015f51 Drop support for old Node format 2015-05-02 22:17:34 +02:00