Skip to content

Commit

Permalink
PHP 8.4 Support: new MyClass()->method() without parentheses (Part 1)
Browse files Browse the repository at this point in the history
- 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'];
```
  • Loading branch information
junichi11 authored and jhorvath committed Jan 10, 2025
1 parent 9088e99 commit ac5ea1f
Show file tree
Hide file tree
Showing 69 changed files with 69,848 additions and 54,948 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ public static String extractQualifiedName(Expression typeName) {
return extractQualifiedName((UnionType) typeName);
} else if (typeName instanceof IntersectionType) {
return extractQualifiedName((IntersectionType) typeName);
} else if (typeName instanceof ClassInstanceCreation) {
// PHP 8.4 new without parentheses new A()->method();
return null;
}
assert false : typeName.getClass();
return null;
Expand Down
5,134 changes: 2,702 additions & 2,432 deletions php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

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

package org.netbeans.modules.php.editor.parser;
Expand Down
6,904 changes: 3,452 additions & 3,452 deletions php/php.editor/src/org/netbeans/modules/php/editor/parser/EncodedActionTable1.java

Large diffs are not rendered by default.

Loading

0 comments on commit ac5ea1f

Please sign in to comment.