Hi Am 2026-02-24 01:45, schrieb Ben Ramsey:
Objects are references, whether or not using the `&` operator.
This is false. Quoting from the PHP documentation at https://www.php.net/manual/en/language.oop5.references.php:
One of the key-points of PHP OOP that is often mentioned is that "objects are passed by references by default". This is not completely true. […] In PHP, an object variable […] contains an object identifier which allows object accessors to find the actual object.
-
Is the idea to allow objects (and arrays) similar to how JavaScript handles these with `const`? That is, the objects and arrays themselves are mutable, but the variable name cannot be reassigned to a new object or array?
The proposed semantics in the RFC are very clearly modeled after the existing behavior of `readonly` properties in PHP: Immutability of identity, which would be “cannot be reassigned”. I'd like to note here that arrays in PHP are values, thus they are immutable when stored in a readonly property (see https://3v4l.org/vS0ij). I expect the same from this RFC, but having array-semantics spelled out explicitly + an example certainly makes sense for clarity.
Best regards Tim Düsterhus
