diff --git a/common/define-grammar.js b/common/define-grammar.js index ddf39443..3c82adf2 100644 --- a/common/define-grammar.js +++ b/common/define-grammar.js @@ -331,7 +331,10 @@ module.exports = function defineGrammar(dialect) { repeat1($._modifier), optional(field('type', $.type)), commaSep1($.property_element), - $._semicolon, + choice( + $._semicolon, + $.property_hook_list, + ), ), _modifier: $ => prec.left(choice( @@ -344,10 +347,27 @@ module.exports = function defineGrammar(dialect) { )), property_element: $ => seq( - $.variable_name, + field('name', $.variable_name), optional(seq('=', field('default_value', $.expression))), ), + property_hook_list: $ => seq('{', repeat($.property_hook), '}'), + + property_hook: $ => seq( + optional(field('attributes', $.attribute_list)), + optional(field('final', $.final_modifier)), + optional(field('reference_modifier', $.reference_modifier)), + $.name, + optional(field('parameters', $.formal_parameters)), + $._property_hook_body, + ), + + _property_hook_body: $ => choice( + seq('=>', field('body', $.expression), $._semicolon), + field('body', $.compound_statement), + $._semicolon, + ), + method_declaration: $ => seq( optional(field('attributes', $.attribute_list)), repeat($._modifier), @@ -475,10 +495,8 @@ module.exports = function defineGrammar(dialect) { field('readonly', optional($.readonly_modifier)), field('type', optional($.type)), // Note: callable is not a valid type here, but instead of complicating the parser, we defer this checking to any intelligence using the parser field('name', $.variable_name), - optional(seq( - '=', - field('default_value', $.expression), - )), + optional(seq('=', field('default_value', $.expression))), + optional($.property_hook_list), ), simple_parameter: $ => seq( @@ -486,10 +504,7 @@ module.exports = function defineGrammar(dialect) { field('type', optional($.type)), optional(field('reference_modifier', $.reference_modifier)), field('name', $.variable_name), - optional(seq( - '=', - field('default_value', $.expression), - )), + optional(seq('=', field('default_value', $.expression))), ), variadic_parameter: $ => seq( @@ -1243,18 +1258,12 @@ module.exports = function defineGrammar(dialect) { _variable_subscript_expression: $ => seq( $._new_variable, - choice( - seq('[', optional($.expression), ']'), - seq('{', $.expression, '}'), - ), + seq('[', optional($.expression), ']'), ), _dereferencable_subscript_expression: $ => seq( $._dereferencable_expression, - choice( - seq('[', optional($.expression), ']'), - seq('{', $.expression, '}'), - ), + seq('[', optional($.expression), ']'), ), _dereferencable_expression: $ => prec(PREC.DEREF, choice( @@ -1266,10 +1275,10 @@ module.exports = function defineGrammar(dialect) { $._name, )), - _dereferencable_scalar: $ => choice( + _dereferencable_scalar: $ => prec(PREC.DEREF, choice( $.array_creation_expression, $._string, - ), + )), array_creation_expression: $ => choice( seq(keyword('array'), '(', commaSep($.array_element_initializer), optional(','), ')'), diff --git a/test/corpus/class.txt b/test/corpus/class.txt index bb23fce7..899bb8f6 100644 --- a/test/corpus/class.txt +++ b/test/corpus/class.txt @@ -22,17 +22,12 @@ abstract class A { (visibility_modifier) (name) (formal_parameters) - (compound_statement) - ) + (compound_statement)) (method_declaration (abstract_modifier) (visibility_modifier) (name) - (formal_parameters) - ) - ) - ) -) + (formal_parameters))))) ========================================= Anonymous classes @@ -145,15 +140,12 @@ if (true) { (program (php_tag) (if_statement - (parenthesized_expression (boolean)) + (parenthesized_expression + (boolean)) (compound_statement (class_declaration (name) - (declaration_list) - ) - ) - ) -) + (declaration_list))))) ========================================= Class constant modifiers @@ -178,32 +170,35 @@ class Foo { (name) (declaration_list (const_declaration - (const_element (name) (integer)) - ) + (const_element + (name) + (integer))) (const_declaration (visibility_modifier) - (const_element (name) (integer)) - ) + (const_element + (name) + (integer))) (const_declaration (visibility_modifier) - (const_element (name) (integer)) - ) + (const_element + (name) + (integer))) (const_declaration (visibility_modifier) - (const_element (name) (integer)) - ) + (const_element + (name) + (integer))) (const_declaration (final_modifier) - (const_element (name) (integer)) - ) + (const_element + (name) + (integer))) (const_declaration (final_modifier) (visibility_modifier) - (const_element (name) (integer)) - ) - ) - ) -) + (const_element + (name) + (integer)))))) ========================================= Typed class constants @@ -227,21 +222,22 @@ class Foo { (const_declaration (visibility_modifier) (primitive_type) - (const_element (name) (integer)) - ) + (const_element + (name) + (integer))) (const_declaration (visibility_modifier) - (optional_type (primitive_type)) - (const_element (name) (array_creation_expression)) - ) + (optional_type + (primitive_type)) + (const_element + (name) + (array_creation_expression))) (const_declaration (visibility_modifier) (primitive_type) - (const_element (name) (boolean)) - ) - ) - ) -) + (const_element + (name) + (boolean)))))) ========================================= Final class @@ -258,9 +254,7 @@ final class A {} (class_declaration (final_modifier) (name) - (declaration_list) - ) -) + (declaration_list))) ========================================= Implicitly public properties and methods @@ -288,44 +282,38 @@ abstract class A { (declaration_list (property_declaration (var_modifier) - (property_element (variable_name (name))) - ) + (property_element + (variable_name + (name)))) (property_declaration (static_modifier) - (property_element (variable_name (name))) - ) + (property_element + (variable_name + (name)))) (method_declaration (abstract_modifier) (name) - (formal_parameters) - ) + (formal_parameters)) (method_declaration (final_modifier) (name) (formal_parameters) - (compound_statement) - ) + (compound_statement)) (method_declaration (static_modifier) (name) (formal_parameters) - (compound_statement) - ) + (compound_statement)) (method_declaration (final_modifier) (static_modifier) (name) (formal_parameters) - (compound_statement) - ) + (compound_statement)) (method_declaration (name) (formal_parameters) - (compound_statement) - ) - ) - ) -) + (compound_statement))))) ========================================= Property Types @@ -343,34 +331,36 @@ class A { --- (program - (php_tag) + (php_tag) (class_declaration name: (name) body: (declaration_list (property_declaration (visibility_modifier) type: (primitive_type) - (property_element (variable_name (name))) - ) + (property_element + name: (variable_name + (name)))) (property_declaration (visibility_modifier) (static_modifier) - type: (named_type (name)) - (property_element (variable_name (name))) - ) + type: (named_type + (name)) + (property_element + name: (variable_name + (name)))) (property_declaration (visibility_modifier) - type: (optional_type (primitive_type)) - (property_element (variable_name (name))) - ) + type: (optional_type + (primitive_type)) + (property_element + name: (variable_name + (name)))) (property_declaration (visibility_modifier) - (property_element (variable_name (name))) - ) - ) - ) -) - + (property_element + name: (variable_name + (name))))))) ========================================= Constructor Property Promotion @@ -400,27 +390,21 @@ class Point { (property_promotion_parameter visibility: (visibility_modifier) type: (primitive_type) - - name: (variable_name (name)) - default_value: (float) - ) + name: (variable_name + (name)) + default_value: (float)) (simple_parameter type: (primitive_type) - name: (variable_name (name)) - default_value: (float) - ) + name: (variable_name + (name)) + default_value: (float)) (property_promotion_parameter visibility: (visibility_modifier) type: (primitive_type) - name: (variable_name (name)) - default_value: (float) - ) - ) - body: (compound_statement) - ) - ) - ) -) + name: (variable_name + (name)) + default_value: (float))) + body: (compound_statement))))) ================================================================================ Readonly properties @@ -506,7 +490,8 @@ class A { (property_declaration (visibility_modifier) (readonly_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name)))) @@ -541,7 +526,8 @@ class A { (property_declaration (readonly_modifier) (visibility_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name)))) @@ -576,7 +562,8 @@ class A { (property_declaration (visibility_modifier) (readonly_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name)))) @@ -611,7 +598,8 @@ class A { (property_declaration (readonly_modifier) (visibility_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name)))) @@ -646,7 +634,8 @@ class A { (property_declaration (visibility_modifier) (readonly_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name)))) @@ -681,7 +670,8 @@ class A { (property_declaration (readonly_modifier) (visibility_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name)))) @@ -711,7 +701,8 @@ class A { (name)))) (property_declaration (readonly_modifier) - (named_type (name)) + (named_type + (name)) (property_element (variable_name (name))))))) @@ -742,16 +733,19 @@ class Point { parameters: (formal_parameters (property_promotion_parameter visibility: (visibility_modifier) - name: (variable_name (name))) + name: (variable_name + (name))) (property_promotion_parameter visibility: (visibility_modifier) readonly: (readonly_modifier) - name: (variable_name (name))) + name: (variable_name + (name))) (property_promotion_parameter visibility: (visibility_modifier) readonly: (readonly_modifier) type: (primitive_type) - name: (variable_name (name)))) + name: (variable_name + (name)))) body: (compound_statement))))) ========================================= @@ -801,9 +795,216 @@ trait Test { (visibility_modifier) (const_element (name) - (integer) - ) - ) - ) - ) -) + (integer)))))) + +========================================= +Property Hooks +========================================= + + strtolower($value); }, + ) {} + public string $fullName { + get => $this->first . " " . $this->last; + set { + [$this->first, $this->last] = explode(' ', $value, 2); + $this->isModified = true; + } + } + public string $foo { + set (string $value) { + return strtoupper($value); + } + } + public string $bar = 'default' { + final set => strtoupper($value); + } + public string $baz { + &get { + return $this->baz; + } + } + public $prop { + #[A] get {} + #[B] set {} + } +} + +--- + +(program + (php_tag) + (interface_declaration + (name) + (declaration_list + (property_declaration + (visibility_modifier) + (primitive_type) + (property_element + (variable_name + (name))) + (property_hook_list + (property_hook + (name)) + (property_hook + (name)))))) + (class_declaration + (name) + (class_interface_clause + (name)) + (declaration_list + (method_declaration + (visibility_modifier) + (name) + (formal_parameters + (property_promotion_parameter + (visibility_modifier) + (primitive_type) + (variable_name + (name)) + (property_hook_list + (property_hook + (name) + (function_call_expression + (name) + (arguments + (argument + (variable_name + (name))))))))) + (compound_statement)) + (property_declaration + (visibility_modifier) + (primitive_type) + (property_element + (variable_name + (name))) + (property_hook_list + (property_hook + (name) + (binary_expression + (binary_expression + (member_access_expression + (variable_name + (name)) + (name)) + (encapsed_string + (string_content))) + (member_access_expression + (variable_name + (name)) + (name)))) + (property_hook + (name) + (compound_statement + (expression_statement + (assignment_expression + (list_literal + (member_access_expression + (variable_name + (name)) + (name)) + (member_access_expression + (variable_name + (name)) + (name))) + (function_call_expression + (name) + (arguments + (argument + (string + (string_content))) + (argument + (variable_name + (name))) + (argument + (integer)))))) + (expression_statement + (assignment_expression + (member_access_expression + (variable_name + (name)) + (name)) + (boolean))))))) + (property_declaration + (visibility_modifier) + (primitive_type) + (property_element + (variable_name + (name))) + (property_hook_list + (property_hook + (name) + (formal_parameters + (simple_parameter + (primitive_type) + (variable_name + (name)))) + (compound_statement + (return_statement + (function_call_expression + (name) + (arguments + (argument + (variable_name + (name)))))))))) + (property_declaration + (visibility_modifier) + (primitive_type) + (property_element + (variable_name + (name)) + (string + (string_content))) + (property_hook_list + (property_hook + (final_modifier) + (name) + (function_call_expression + (name) + (arguments + (argument + (variable_name + (name)))))))) + (property_declaration + (visibility_modifier) + (primitive_type) + (property_element + (variable_name + (name))) + (property_hook_list + (property_hook + (reference_modifier) + (name) + (compound_statement + (return_statement + (member_access_expression + (variable_name + (name)) + (name))))))) + (property_declaration + (visibility_modifier) + (property_element + (variable_name + (name))) + (property_hook_list + (property_hook + (attribute_list + (attribute_group + (attribute + (name)))) + (name) + (compound_statement)) + (property_hook + (attribute_list + (attribute_group + (attribute + (name)))) + (name) + (compound_statement))))))) diff --git a/test/corpus/declarations.txt b/test/corpus/declarations.txt index 175d6367..29a0dc69 100644 --- a/test/corpus/declarations.txt +++ b/test/corpus/declarations.txt @@ -19,7 +19,7 @@ class Exception_foo implements ThrowableInterface { --- (program - (php_tag) + (php_tag) (interface_declaration name: (name) body: (declaration_list @@ -29,21 +29,26 @@ class Exception_foo implements ThrowableInterface { parameters: (formal_parameters)))) (class_declaration name: (name) - (class_interface_clause (name)) + (class_interface_clause + (name)) body: (declaration_list (property_declaration (visibility_modifier) (property_element - (variable_name (name)) - default_value: (encapsed_string (string_content)))) + name: (variable_name + (name)) + default_value: (encapsed_string + (string_content)))) (method_declaration (visibility_modifier) name: (name) parameters: (formal_parameters) body: (compound_statement - (return_statement (member_access_expression - object: (variable_name (name)) - name: (name)))))))) + (return_statement + (member_access_expression + object: (variable_name + (name)) + name: (name)))))))) ========================== Use declarations @@ -70,22 +75,38 @@ class AbstractCache --- (program - (php_tag) + (php_tag) (trait_declaration (name) (declaration_list - (use_declaration (name)) - (use_declaration (name) (name) (use_list)) - (use_declaration (name) (name)))) + (use_declaration + (name)) + (use_declaration + (name) + (name) + (use_list)) + (use_declaration + (name) + (name)))) (class_declaration (name) (declaration_list (use_declaration (name) (use_list - (use_as_clause (name) (visibility_modifier)) - (use_as_clause (class_constant_access_expression (name) (name)) (name)) - (use_as_clause (class_constant_access_expression (name) (name)) (name))))))) + (use_as_clause + (name) + (visibility_modifier)) + (use_as_clause + (class_constant_access_expression + (name) + (name)) + (name)) + (use_as_clause + (class_constant_access_expression + (name) + (name)) + (name))))))) ========================== Namespace names in namespaces @@ -101,9 +122,11 @@ namespace Be \ ta { --- (program - (php_tag) + (php_tag) (namespace_definition - name: (namespace_name (name) (name)) + name: (namespace_name + (name) + (name)) body: (compound_statement (class_declaration name: (name) @@ -132,37 +155,59 @@ class foo { --- (program - (php_tag) + (php_tag) (class_declaration - name: (name) - body: (declaration_list - (method_declaration - name: (name) - parameters: (formal_parameters - (simple_parameter - name: (variable_name (name)))) - body: (compound_statement - (expression_statement (reference_assignment_expression - left: (subscript_expression (variable_name (name)) (string (string_content))) - right: (variable_name (name)))) - (expression_statement (assignment_expression - left: (member_access_expression - object: (variable_name (name)) - name: (name)) - right: (variable_name (name)))) - (expression_statement (member_call_expression - object: (subscript_expression (variable_name (name)) (string (string_content))) - name: (name) - arguments: (arguments))))) - (method_declaration - name: (name) - parameters: (formal_parameters) - body: (compound_statement - (expression_statement (assignment_expression - left: (subscript_expression (subscript_expression (variable_name (name)) (string (string_content)))) - right: (member_access_expression - object: (variable_name (name)) - name: (name))))))))) + name: (name) + body: (declaration_list + (method_declaration + name: (name) + parameters: (formal_parameters + (simple_parameter + name: (variable_name + (name)))) + body: (compound_statement + (expression_statement + (reference_assignment_expression + left: (subscript_expression + (variable_name + (name)) + (string + (string_content))) + right: (variable_name + (name)))) + (expression_statement + (assignment_expression + left: (member_access_expression + object: (variable_name + (name)) + name: (name)) + right: (variable_name + (name)))) + (expression_statement + (member_call_expression + object: (subscript_expression + (variable_name + (name)) + (string + (string_content))) + name: (name) + arguments: (arguments))))) + (method_declaration + name: (name) + parameters: (formal_parameters) + body: (compound_statement + (expression_statement + (assignment_expression + left: (subscript_expression + (subscript_expression + (variable_name + (name)) + (string + (string_content)))) + right: (member_access_expression + object: (variable_name + (name)) + name: (name))))))))) ======================================== Class declarations with base classes @@ -176,11 +221,12 @@ class A extends B { --- (program - (php_tag) - (class_declaration - name: (name) - (base_clause (name)) - body: (declaration_list))) + (php_tag) + (class_declaration + name: (name) + (base_clause + (name)) + body: (declaration_list))) ========================== Function parameters @@ -194,17 +240,19 @@ function test(int $a, string ...$b) --- (program - (php_tag) - (function_definition - name: (name) - parameters: (formal_parameters - (simple_parameter - type: (primitive_type) - name: (variable_name (name))) - (variadic_parameter - type: (primitive_type) - name: (variable_name (name)))) - body: (compound_statement))) + (php_tag) + (function_definition + name: (name) + parameters: (formal_parameters + (simple_parameter + type: (primitive_type) + name: (variable_name + (name))) + (variadic_parameter + type: (primitive_type) + name: (variable_name + (name)))) + body: (compound_statement))) ==================================== Functions with default parameters @@ -218,14 +266,20 @@ function a($arg = self::bar) { --- (program - (php_tag) - (function_definition - (name) - (formal_parameters - (simple_parameter - (variable_name (name)) - (class_constant_access_expression (relative_scope) (name)))) - (compound_statement (echo_statement (variable_name (name)))))) + (php_tag) + (function_definition + (name) + (formal_parameters + (simple_parameter + (variable_name + (name)) + (class_constant_access_expression + (relative_scope) + (name)))) + (compound_statement + (echo_statement + (variable_name + (name)))))) ======================================================================== Static variables in functions @@ -240,14 +294,20 @@ function blah() --- (program - (php_tag) - (function_definition - (name) - (formal_parameters) - (compound_statement - (function_static_declaration - (static_variable_declaration (variable_name (name)) (integer)) - (static_variable_declaration (variable_name (name)) (integer)))))) + (php_tag) + (function_definition + (name) + (formal_parameters) + (compound_statement + (function_static_declaration + (static_variable_declaration + (variable_name + (name)) + (integer)) + (static_variable_declaration + (variable_name + (name)) + (integer)))))) ========================================= Defining Constants @@ -273,52 +333,55 @@ define('ANIMALS', array( (function_call_expression (name) (arguments - (argument (encapsed_string (string_content))) - (argument (encapsed_string (string_content))) - ) - ) - ) + (argument + (encapsed_string + (string_content))) + (argument + (encapsed_string + (string_content)))))) (const_declaration (const_element (name) - (string (string_content)) - ) - ) + (string + (string_content)))) (const_declaration (const_element (name) (binary_expression (name) - (string (string_content)) - ) - ) - ) + (string + (string_content))))) (const_declaration (const_element (name) (array_creation_expression - (array_element_initializer (string (string_content))) - (array_element_initializer (string (string_content))) - (array_element_initializer (string (string_content))) - ) - ) - ) + (array_element_initializer + (string + (string_content))) + (array_element_initializer + (string + (string_content))) + (array_element_initializer + (string + (string_content)))))) (expression_statement (function_call_expression (name) (arguments - (argument (string (string_content))) + (argument + (string + (string_content))) (argument (array_creation_expression - (array_element_initializer (string (string_content))) - (array_element_initializer (string (string_content))) - (array_element_initializer (string (string_content))) - ) - ) - ) - ) - ) -) + (array_element_initializer + (string + (string_content))) + (array_element_initializer + (string + (string_content))) + (array_element_initializer + (string + (string_content))))))))) ======================================= Attributes @@ -387,84 +450,90 @@ class B { (program (php_tag) - (function_definition - attributes: (attribute_list (attribute_group (attribute (name)))) + attributes: (attribute_list + (attribute_group + (attribute + (name)))) name: (name) parameters: (formal_parameters (simple_parameter attributes: (attribute_list - (attribute_group (attribute (name))) - ) - name: (variable_name (name)) - ) - ) - body: (compound_statement (expression_statement (variable_name (name)))) - ) - + (attribute_group + (attribute + (name)))) + name: (variable_name + (name)))) + body: (compound_statement + (expression_statement + (variable_name + (name))))) (class_declaration name: (name) body: (declaration_list (const_declaration - attributes: (attribute_list (attribute_group (attribute (name)))) - (const_element (name) (string (string_content))) - ) - + attributes: (attribute_list + (attribute_group + (attribute + (name)))) + (const_element + (name) + (string + (string_content)))) (property_declaration - attributes: (attribute_list (attribute_group (attribute (name)))) + attributes: (attribute_list + (attribute_group + (attribute + (name)))) (visibility_modifier) type: (primitive_type) - (property_element (variable_name (name)) - default_value: (string) - ) - ) + (property_element + name: (variable_name + (name)) + default_value: (string))) (method_declaration attributes: (attribute_list (attribute_group (attribute (name) parameters: (arguments - (argument (encapsed_string (string_content))) + (argument + (encapsed_string + (string_content))) (argument (array_creation_expression - (array_element_initializer (encapsed_string (string_content))) - ) - ) - ) - ) - ) - ) + (array_element_initializer + (encapsed_string + (string_content))))))))) (visibility_modifier) name: (name) parameters: (formal_parameters (simple_parameter - attributes: (attribute_list (attribute_group (attribute (name)))) - name: (variable_name (name)) - ) - ) - body: (compound_statement (comment)) - ) - ) - ) + attributes: (attribute_list + (attribute_group + (attribute + (name)))) + name: (variable_name + (name)))) + body: (compound_statement + (comment))))) (class_declaration attributes: (attribute_list (attribute_group - (attribute (name)) - ) + (attribute + (name))) (attribute_group (attribute (qualified_name - prefix: (namespace_name (name)) - (name) - ) - ) - ) + prefix: (namespace_name + (name)) + (name)))) (attribute_group (attribute (name) - parameters: (arguments (argument (integer))) - ) - ) + parameters: (arguments + (argument + (integer))))) (attribute_group (attribute (name) @@ -472,12 +541,7 @@ class B { (argument (class_constant_access_expression (name) - (name) - ) - ) - ) - ) - ) + (name)))))) (attribute_group (attribute (name) @@ -485,14 +549,10 @@ class B { (argument (array_creation_expression (array_element_initializer - (encapsed_string (string_content)) - (encapsed_string (string_content)) - ) - ) - ) - ) - ) - ) + (encapsed_string + (string_content)) + (encapsed_string + (string_content)))))))) (attribute_group (attribute (name) @@ -500,16 +560,9 @@ class B { (argument (binary_expression left: (integer) - right: (integer) - ) - ) - ) - ) - ) - ) + right: (integer))))))) name: (name) - body: (declaration_list) - ) + body: (declaration_list)) (expression_statement (object_creation_expression (anonymous_class @@ -521,33 +574,33 @@ class B { body: (declaration_list)))) (expression_statement (arrow_function - attributes: (attribute_list (attribute_group (attribute (name)))) + attributes: (attribute_list + (attribute_group + (attribute + (name)))) parameters: (formal_parameters (simple_parameter - name: (variable_name (name)) - ) - ) - body: (variable_name (name)) - ) - ) + name: (variable_name + (name)))) + body: (variable_name + (name)))) (expression_statement (assignment_expression - left: (variable_name (name)) + left: (variable_name + (name)) right: (anonymous_function - attributes: (attribute_list (attribute_group (attribute (name)))) + attributes: (attribute_list + (attribute_group + (attribute + (name)))) parameters: (formal_parameters (simple_parameter - name: (variable_name (name)) - ) - ) + name: (variable_name + (name)))) body: (compound_statement (return_statement - (variable_name (name)) - ) - ) - ) - ) - ) + (variable_name + (name))))))) (class_declaration name: (name) body: (declaration_list @@ -556,82 +609,71 @@ class B { (attribute_group (attribute (qualified_name - prefix: (namespace_name (name)) + prefix: (namespace_name + (name)) (name)) parameters: (arguments (argument (object_creation_expression (qualified_name - prefix: (namespace_name (name)) + prefix: (namespace_name + (name)) (name)))) (argument (object_creation_expression (qualified_name - prefix: (namespace_name (name)) - (name) - ) + prefix: (namespace_name + (name)) + (name)) (arguments (argument name: (name) - (integer) - ) - ) - ) - ) - ) - ) - ) - ) + (integer))))))))) (visibility_modifier) type: (primitive_type) (property_element - (variable_name (name)) - default_value: (string) - ) - ) - ) - ) + name: (variable_name + (name)) + default_value: (string))))) (function_definition attributes: (attribute_list (attribute_group - (attribute (name)) + (attribute + (name)) (attribute (name) - parameters: (arguments) - ) + parameters: (arguments)) (attribute (name) - parameters: (arguments (argument (integer))) - ) + parameters: (arguments + (argument + (integer)))) (attribute (name) - parameters: (arguments (argument name: (name) (integer))) - ) - ) - ) + parameters: (arguments + (argument + name: (name) + (integer)))))) name: (name) parameters: (formal_parameters) body: (compound_statement)) - (class_declaration - name: (name) - body: (declaration_list - (method_declaration - (visibility_modifier) - name: (name) - parameters: (formal_parameters - (property_promotion_parameter - attributes: (attribute_list - (attribute_group - (attribute - (name)))) - visibility: (visibility_modifier) - type: (primitive_type) - name: (variable_name - (name)))) - body: (compound_statement))) - ) -) - + (class_declaration + name: (name) + body: (declaration_list + (method_declaration + (visibility_modifier) + name: (name) + parameters: (formal_parameters + (property_promotion_parameter + attributes: (attribute_list + (attribute_group + (attribute + (name)))) + visibility: (visibility_modifier) + type: (primitive_type) + name: (variable_name + (name)))) + body: (compound_statement))))) ======================================= Enums @@ -668,30 +710,40 @@ enum Suit: string (php_tag) (enum_declaration (name) - (enum_declaration_list) - ) + (enum_declaration_list)) (enum_declaration (name) (class_interface_clause (name) - (name) - ) - (enum_declaration_list) - ) + (name)) + (enum_declaration_list)) (enum_declaration (name) (primitive_type) - (class_interface_clause (name)) - (enum_declaration_list) - ) + (class_interface_clause + (name)) + (enum_declaration_list)) (enum_declaration (name) (primitive_type) (enum_declaration_list - (enum_case (name) (string (string_content))) - (enum_case (name)) - (enum_case (name) (encapsed_string (string_content))) - (enum_case (name) (heredoc (heredoc_start) (heredoc_body (string_content)) (heredoc_end))) + (enum_case + (name) + (string + (string_content))) + (enum_case + (name)) + (enum_case + (name) + (encapsed_string + (string_content))) + (enum_case + (name) + (heredoc + (heredoc_start) + (heredoc_body + (string_content)) + (heredoc_end))) (comment) (method_declaration (visibility_modifier) @@ -702,28 +754,26 @@ enum Suit: string (return_statement (match_expression (parenthesized_expression - (variable_name (name)) - ) + (variable_name + (name))) (match_block (match_conditional_expression (match_condition_list - (class_constant_access_expression (name) (name)) - (class_constant_access_expression (name) (name)) - ) - (string (string_content)) - ) + (class_constant_access_expression + (name) + (name)) + (class_constant_access_expression + (name) + (name))) + (string + (string_content))) (match_conditional_expression (match_condition_list - (class_constant_access_expression (name) (name)) - (class_constant_access_expression (name) (name)) - ) - (string (string_content)) - ) - ) - ) - ) - ) - ) - ) - ) -) + (class_constant_access_expression + (name) + (name)) + (class_constant_access_expression + (name) + (name))) + (string + (string_content)))))))))))