Skip to content
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

Modifying properties by reference should be forbidden for @immutable #4068

Closed
vudaltsov opened this issue Aug 26, 2020 · 3 comments
Closed

Comments

@vudaltsov
Copy link
Contributor

https://psalm.dev/r/772662e57b

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/772662e57b
<?php

declare(strict_types=1);

/**
 * @psalm-immutable
 */
class Obj
{
    public string $property = 'read-only value';
}

$obj = new Obj();
$property = &$obj->property;
$property = 'mutated value';
Psalm output (using commit 20e0047):

No issues!

@vudaltsov vudaltsov changed the title Modifying properties by reference is not forbidden for @immutable Modifying properties by reference should be forbidden for @immutable Aug 26, 2020
@klimick
Copy link
Contributor

klimick commented Jun 8, 2023

Psalm throws UnsupportedPropertyReferenceUsage after #9769

@vudaltsov
Copy link
Contributor Author

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants