Req #63471 [Opn->Csd]: Make properties final on runtime

From: Date: Thu, 02 Dec 2021 22:55:51 +0000
Subject: Req #63471 [Opn->Csd]: Make properties final on runtime
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238122@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63471&edit=1 ID: 63471 Updated by: ilutov@php.net Reported by: daniel at baz-x dot at Summary: Make properties final on runtime -Status: Open +Status: Closed Type: Feature/Change Request Package: Reflection related Operating System: Any PHP Version: 5.4.8 -Assigned To: +Assigned To: ilutov Block user comment: N Private report: N New Comment: Thank you for your bug report. This issue has already been fixed in the latest released version of PHP, which you can download at http://www.php.net/downloads.php PHP 8.1 adds native enum support. We also have readonly properties, although static properties aren't supported. Making properties readonly now through other means is probably not a great idea. Previous Comments: ------------------------------------------------------------------------ [2012-11-10 18:20:50] 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). ------------------------------------------------------------------------ [2012-11-09 17:56:33] mail+php at requinix dot net There's actually an RFC for an enum type: https://wiki.php.net/rfc/enum. ------------------------------------------------------------------------ [2012-11-09 09:59:05] daniel at baz-x dot at Description: ------------ 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: https://dl.dropbox.com/u/11045888/Enum.php.txt Implementation: https://dl.dropbox.com/u/11045888/QueryType.php.txt ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63471&edit=1

« previous php.bugs (#238122) next »