> Hi,

> The RFC talks only about global constants. What about class constants? It
is somewhat
> cumbersome to get a mutable object in this position, but it is
nevertheless possible, and,
> at least for consistency, it should be ensured that they are treated the
same way as global constants:

> https://3v4l.org/QhM1L

Hi Claude,

Good point, thanks. I've extended the implementation so they're handled the
same way; both forms
from your example now work:

c::o->b = 42;
$c::o->b = 42;

One consequence worth flagging: enum cases are class constants, so
unset(Enum::Case->value)
(and writes to readonly case properties) now raise the regular runtime
readonly-property Error instead of
the old compile-time "temporary expression" error, i.e. identical to $x =
Enum::Case; unset($x->value);.
Enum case properties remain immutable.

I've updated the PR (#20903) and bumped the RFC
<https://wiki.php.net/rfc/const_object_property_write> to v0.3 to cover
this. Since it widens the scope,
I'll restart the discussion cooldown and push the vote date back
accordingly.

Best regards,
__

*Khaled Alam*


On Mon, Jun 22, 2026 at 12:01 AM Claude Pache <[email protected]>
wrote:

>
>
> Le 21 juin 2026 à 20:33, Khaled Alam <[email protected]> a écrit :
>
> 
> Hi all,
>
> Reviving this thread. The v0.2 RFC
> <https://wiki.php.net/rfc/const_object_property_write> (object property
> writes on constants only;
> array/dim writes removed) addressed Tim's concerns, and the 14-day
> cooldown has long passed.
>
> Unless there are further objections, I intend to open voting on Monday, 29
> June 2026. 2/3 majority,
> targets PHP 8.6, two-week vote.
>
> RFC: https://wiki.php.net/rfc/const_object_property_write
> PR:  https://github.com/php/php-src/pull/20903
>
> Best regards,
> __
> *Khaled Alam*
>
>
> Hi,
>
> The RFC talks only about global constants. What about class constants? It
> is somewhat cumbersome to get a mutable object in this position, but it is
> nevertheless possible, and, at least for consistency, it should be ensured
> that they are treated the same way as global constants:
>
> https://3v4l.org/QhM1L
>
>
>
> —Claude
>
>

Reply via email to