|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63471 Make properties final on runtime
Submitted: 2012-11-09 09:59 UTC Modified: -
From: daniel at baz-x dot at Assigned:
Status: Open Package: Reflection related
PHP Version: 5.4.8 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:
Solve the problem:
47 - 16 = ?
Subscribe to this entry?

 [2012-11-09 09:59 UTC] daniel at baz-x dot at
I have developed a class that tries to mimic java like enums as much as possible 
(only the simple ones, see provided urls for the example). The only difficulty I 
got is that it's still possible to overwrite the static variables which makes the 
enum quite insecure.
As I would like to keep it as much as it's like in java I would like to request 
for a reflection method to make properties final (at least for the static ones) 
like ReflectionProperty->setFinal().

Test script:
Enum class:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-09 17:56 UTC] mail+php at requinix dot net
There's actually an RFC for an enum type:
 [2012-11-10 18:20 UTC] daniel at baz-x dot at
Ah ok, but this request is not only restricted to enums. It could also be used in 
constructors to fill properties (especially with objects) and make them final 
afterwards so they can't be changed just like in java.
Of what I've read on the rfc is that it seems like those enums won't behave like 
objects while my implementation provides methods (sorry for the bad english).
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Apr 16 18:01:23 2021 UTC