Skip to content

Commit eda6940

Browse files
committed
PHP 8.4 Support: new MyClass()->method() without parentheses (Part 1)
- apache#8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/new_without_parentheses - Fix the gramar file(`ASTPHP5Parser.cup`) - Add the `PHP84UnhandledError` - Add unit tests for the parser Example: ```php new Example()->method(); new $class()?->method(); new Example()::staticMethod1()::CONSTANT; new (trim(' Example '))()::staticMethod1()->field; new Example()::{'CONSTANT'}; new Example()(); new $class()(); new Example()['key']; new $class()['key']; new (trim(' Example '))()['key']; // anonymous classes echo new class { const CONSTANT = 'constant'; }::CONSTANT; new class { public function method() {} }->method(); new class () implements ArrayAccess { }['key']; ```
1 parent 4aa7f77 commit eda6940

File tree

69 files changed

+69848
-54948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+69848
-54948
lines changed

php/php.editor/src/org/netbeans/modules/php/editor/CodeUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ public static String extractQualifiedName(Expression typeName) {
330330
return extractQualifiedName((UnionType) typeName);
331331
} else if (typeName instanceof IntersectionType) {
332332
return extractQualifiedName((IntersectionType) typeName);
333+
} else if (typeName instanceof ClassInstanceCreation) {
334+
// PHP 8.4 new without parentheses new A()->method();
335+
return null;
333336
}
334337
assert false : typeName.getClass();
335338
return null;

php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java

Lines changed: 2702 additions & 2432 deletions
Large diffs are not rendered by default.

php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
//----------------------------------------------------
2121
// The following code was generated by CUP v0.11a beta 20060608
22-
// Thu Dec 19 14:22:13 JST 2024
22+
// Mon Jan 06 13:39:03 JST 2025
2323
//----------------------------------------------------
2424

2525
package org.netbeans.modules.php.editor.parser;

php/php.editor/src/org/netbeans/modules/php/editor/parser/EncodedActionTable1.java

Lines changed: 3452 additions & 3452 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)