Commit Graph

30 Commits

Author SHA1 Message Date
Tomas Votruba
f68e1a43ff
[PHP 8.1] Add support for enums (#758)
RFC: https://wiki.php.net/rfc/enumerations

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-04-25 21:11:36 +02:00
Tomas Votruba
4c22c62783
[PHP 8.0] Add attributes support (#661)
Adds support for PHP 8 attributes, represented using `AttrGroup` nodes
containing `Attribute` nodes. The `attrGroup` subnode is added to all
nodes that can have attributes.

This is still missing FPPP support.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-09-13 21:01:17 +02:00
Tomas Votruba
005bb1dba7 add getProperties() and getConstants() to ClassLike 2019-08-30 20:47:14 +02:00
Nikita Popov
993f29906b Avoid parent constructor call during node construction
Instead explicitly assign the attributes. This is a minor
performance improvement.
2019-05-12 14:55:21 +02:00
Gabriel Caruso
248b29ecf6 Add public visibility to getType method (#463) 2018-01-10 18:57:48 +01:00
Nikita Popov
1c11626f0a Add explicit getType() methods
Rather than automatically deriving getType() from the class name.
2017-11-12 21:27:14 +01:00
TomasVotruba
e2e99f269b Add strict_types to lib code 2017-08-18 23:00:13 +02:00
Nikita Popov
7b36ca3b6c Add isSpecialClassName() method to Identifier and Name 2017-08-15 22:59:52 +02:00
TomasVotruba
ec535ea14e [cs] use PHP 5.4 short array, since PHP 7.0 is min version 2017-08-13 21:14:28 +02:00
Nikita Popov
a32e3797d4 Generate PHP 7 type annotations 2017-04-28 21:40:59 +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
888b9dcf30 Drop misspellt class constant 2017-04-27 18:28:10 +02:00
Nikita Popov
fba61390d8 Use null-coalesce operator 2017-04-24 22:32:40 +02:00
Nikita Popov
ba85da88a0 Merge branch '3.x' 2017-04-19 11:20:32 +02:00
Nikita Popov
901b895c02 Fix spelling of VISIBILITY_MODIFIER_MASK 2017-04-19 11:20:05 +02:00
Nikita Popov
bfea338d36 Update doc comments after previous comment
Make some of the type annotations more accurate, and complete the
generated doc-comments to be complete (with description and
parameter annotations.)
2017-01-26 00:16:54 +01:00
Matthew Brown
e3b87f40aa Add non-void return types 2017-01-25 23:32:50 +01:00
Nikita Popov
0c9c8d58ab Drop deprecated $type subnodes
These have been replaced by $flags in 3.0
2017-01-19 21:00:44 +01:00
Nikita Popov
bcdfb703d5 Cleanup imports
Thanks PhpStorm :)
2016-11-23 22:58:18 +01: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
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
29b9015f51 Drop support for old Node format 2015-05-02 22:17:34 +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
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
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
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
nikic
0f69f12b94 Use "public" visibility when not explicitly given
Fixes issue #143
2014-11-13 20:21:21 +01:00
nikic
3d40e2217d Annotate some APIs as @internal 2014-09-30 20:26:06 +02:00
Nikita Popov
c341ab2ecf Make autoloader for new names PSR-0 compliant 2014-04-02 09:44:45 +02:00