Re: [php-src] PR #20903: GH-10497 (const obj->prop write) - language change notes

From: Date: Thu, 22 Jan 2026 08:31:16 +0000
Subject: Re: [php-src] PR #20903: GH-10497 (const obj->prop write) - language change notes
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-129839@lists.php.net to get a copy of this message
Hi Am 2026-01-22 00:33, schrieb Ilija Tovilo:
No strong opinions on my part, but I'd like to point out that similar situations already exist. https://3v4l.org/ARMMS#v8.4.14
    const C = [1, 2, 3];
    function foo(): array {
        return C;
    }
    foo()[] = 4;
    var_dump(C);
PHP will happily duplicate the array returned from foo() to append 4, without warning. The original array in C remains unmodified. It might
I'm aware. However to me this situation is a little different, intuition-wise: A return value already looks and feels like a temporary value to me (unless a by-ref return is used, of course, but those are rare). An access on a const does not.
make sense for ASSIGN_DIM to warn/throw if OP1 is not a "pointer" (indirect, reference or object), as then the operation will never have an effect. But it seems to me this is a distinct issue.
That makes sense to me and IMO is a necessary precursor for this. Best regards Tim Düsterhus

« previous php.internals (#129839) next »