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

From: Date: Fri, 14 Jan 2022 10:59:52 +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-239006@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/7942 Comment Author: pthreat However one must note that the following example works as intended: ```php <?php // lint >= 8.1 namespace ReadonlyPropertyPassedByRef; class Foo { public readonly int $bar; public function set(int &$i) { $this->bar = &$i; } } $i = 1; $z = 25; $foo = new Foo(); $foo->set($i); $i = &$z; var_dump($foo->bar); ``` The reference of the variable has been set as read only, not it's value.

« previous php.bugs (#239006) next »