php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72007 java-like anonymous classes
Submitted: 2016-04-11 21:02 UTC Modified: 2016-04-11 21:55 UTC
From: matteo_tassinari_TM at libero dot it Assigned:
Status: Suspended Package: Class/Object related
PHP Version: Next Minor Version OS: Any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
26 + 35 = ?
Subscribe to this entry?

 
 [2016-04-11 21:02 UTC] matteo_tassinari_TM at libero dot it
Description:
------------
I would like to suggest to implement anonymous class declaration as done in Java, while maintaining compatibility with current syntax.

Currently, in order to extend a class or implement an interface, you would need to write:

new class (construct params) extends Base implements Interface { ... }

however, this could be simplified as

new MyClass { .. }

as equivalent to

new class() extends MyClass { ... }

or else

new MyInterface { ... }

as equivalent to

new class() implements MyInterface { ... }

This would also help better those with a Java background use them, even if it is just syntactinc sugar.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-11 21:55 UTC] requinix@php.net
-Status: Open +Status: Suspended
 [2016-04-11 21:55 UTC] requinix@php.net
The current syntax for anonymous classes is the one supported.

A change like this requires going through the RFC process.
https://wiki.php.net/rfc/howto
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 07:01:29 2024 UTC