[php-src] Issue #7942: Readonly properties mutable when assigning reference to them

From: Date: Fri, 14 Jan 2022 11:28:32 +0000
Subject: [php-src] Issue #7942: Readonly properties mutable when assigning reference to them
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239008@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7942 Comment Author: iluuu1994 /cc @nikic The engine does prevent creating references from readonly properties. https://3v4l.org/cRgNM#v8.1.1 Maybe we could do the same in the other direction. https://3v4l.org/M1n37#v8.1.1 ```php class Foo { public readonly int $bar; public function __construct(int &$bar) { // Error right here, can't assign reference $this->bar = &$bar; } } $i = 42; $foo = new Foo($i); $i++; var_dump($foo->bar); ```

« previous php.bugs (#239008) next »