It passed with 17 votes in favor, 2 against and 6 abstaining, clearing the two-thirds majority it needed. Voting closed on August 8, 2026, and the change is implemented in PHP 8.6.
Lets you write, unset and increment properties on an object held by a constant, like OBJ->prop = 1, which was a fatal error before.
This poll has closed.
It passed with 17 votes in favor, 2 against and 6 abstaining, clearing the two-thirds majority it needed. Voting closed on August 8, 2026, and the change is implemented in PHP 8.6.
Since PHP 8.1, a constant can hold an object, but you couldn't change that object's properties through the constant. Writing OBJ->prop = 1 stopped with a fatal error. This RFC from Khaled Alam lets you write to properties on an object that a constant references.
A constant can't be reassigned to point at something new, and that doesn't change. Objects in PHP, however, have always been mutable. Updating a property doesn't touch the constant at all, only the object it refers to. The RFC says the old error came from a compiler check that was too broad, not from any rule that constants must be frozen.
const OBJ = new stdClass(); OBJ->value = 123; var_dump(OBJ->value); // int(123) unset(OBJ->value); var_dump(isset(OBJ->value)); // bool(false)
It works for class constants too:
const BACKING = new stdClass(); class C { const O = BACKING; } C::O->prop = 42; var_dump(C::O->prop); // int(42)
You can also use ++, += and .= on those properties, set nested properties like OBJ->a->b, and pass a property by reference to a function.
Some things stay the same:
OBJ = new stdClass(); is still a parse error, because the constant itself can't change.ARR[0] = 9 are still rejected.Code that used to fail now runs. One behavior does shift, because enum cases are class constants. Writing to a case property, like unset(Enum::Case->value), used to fail at compile time. Now it fails at runtime with the usual "Cannot modify readonly property" error, so enum case properties still can't be changed. Static analyzers may need a small update to stop flagging these writes.