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

From: Date: Thu, 15 Jan 2026 06:36:03 +0000
Subject: [php-src] PR #20903: GH-10497 (const obj->prop write) - language change notes
Groups: php.internals 
Request: Send a blank email to internals+get-129757@lists.php.net to get a copy of this message
Hi internals, I opened PR #20903 <https://github.com/php/php-src/pull/20903> to address GH-10497 <https://github.com/php/php-src/issues/10497> by allowing writes to properties of objects referenced by consts (const binding stays immutable, referenced objects can be mutable). class C { public int $x = 0; } const OBJ = new C(); OBJ->x = 1; // currently rejected, PR makes it valid var_dump(OBJ->x); // 1 Notes: - This is a language/semantics change and may overlap with / impact GH-13800 <https://github.com/php/php-src/pull/13800>. - A potentially surprising case: some newly-valid writes can be a no-op when they target a temporary const value, e.g. - const X = [1,2,3]; X[] = 4; - const Y = ['a' => 1]; Y['b'] = 2; These become valid syntax but have no effect because the write happens on a temporary basis. Feedback on semantics + expected behavior for the temporary-write case is appreciated. Thanks, __ *Khaled Alam*

« previous php.internals (#129757) next »