Re: Access property of object stored in a constant
| From: | Larry Garfield | Date: | Sat, 19 Aug 2023 16:54:36 +0000 |
| Subject: | Re: Access property of object stored in a constant | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120921@lists.php.net to get a copy of this message | ||
On Sat, Aug 19, 2023, at 4:21 AM, Claude Pache wrote:
> At the time I filed
> https://github.com/php/php-src/issues/10497, I was
> merely exploring the potential of the new ability to have an object in
> a constant. The potential use I had back in my head was the following.
> Currently, I store some settings in global constants. I was
> contemplating replacing those by properties of a readonly object stored
> in a global constant. (A fatal issue I discovered later in my journey
> is that readonly properties can only be initialised by code inside the
> class itself.)
As a tangent here, that has a workaround:
https://peakd.com/hive-168588/@crell/php-tricks-access-control-bypass
Which I make use of in Crell/Serde, which is then used by my own config library to produce exactly
what you describe:
https://github.com/Crell/Config
--Larry Garfield