-
Notifications
You must be signed in to change notification settings - Fork 7.9k
modify readonly class property with reference #10844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks very related to #9432 |
Also related, it's possible to skip the reference type check: class A implements IteratorAggregate {
function __construct(
public string $foo = 'bar'
) {}
function getIterator(): Traversable {
return new ArrayIterator($this);
}
}
$obj = new A;
foreach ($obj as $k => &$v) {
$v = 42;
}
var_dump($obj);
// object(A)#1 (1) {
// ["foo"]=>
// &int(42)
// } |
This seems fairly difficult to fix. The problem is that We could specifically fix this for It's not pretty but I don't know how else we could solve this without modifying both the iterator API and the internals of spl_object quite heavily. |
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
8.2.3
Operating System
No response
The text was updated successfully, but these errors were encountered: