junichi11 commented on code in PR #8117:
URL: https://github.com/apache/netbeans/pull/8117#discussion_r1904260272
##########
php/php.editor/tools/ASTPHP5Parser.cup:
##########
@@ -5286,6 +5301,33 @@ base_variable_with_function_calls:var T_OBJECT_OPERATOR
object_property:memberPr
RESULT = new FieldAccess(classNameleft, varNameright, new
StaticConstantAccess(classNameleft, constantright, className, constant),
new Variable(varNameleft, varNameright, varName.getName()), true);
:}
+
+// PHP 8.4 new MyClass()->method() without parentheses
+// https://wiki.php.net/rfc/new_without_parentheses
+| new_expr:expr access_operator:operator object_property:memberProperty
method_or_not:paramsList array_access_or_not:aa variable_properties:propertyList
+{:
+ // new Example()->method()
+ // new Example()->method()::staticMethod();
+ // new class(){}->method();
+ // new class(){}->method()::staticMethod();
+ // new Example()?->method()
+ // new Example()?->method()::staticMethod();
+ // new class(){}?->method();
+ // new class(){}?->method()::staticMethod();
+ // new Example()::CONSTANT;
+ // new class(){}::CONSTANT;
+ RESULT = parser.createDispatch(operator, new
ClassInstanceCreationVariable(expr), memberProperty, memberPropertyleft,
memberPropertyright, paramsList, paramsListright, propertyList, aa);
+:}
+
+| new_expr:expr access_operator:operator
+{:
+ // for code completion
+ // e.g. new class() {}::
+ // PHP Parse error: syntax error, unexpected token ";", expecting
identifier or variable or "{" or "$"
+ parser.syntax_error();
Review Comment:
Add an error because this case is a syntax error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists