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

@psalm-immutable reports ImpurePropertyAssignment with class-strings #3738

Closed
Shira-3749 opened this issue Jul 3, 2020 · 1 comment
Closed
Labels

Comments

@Shira-3749
Copy link

https://psalm.dev/r/d68a6a8abf

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/d68a6a8abf
<?php

/**
 * @psalm-immutable
 */
class Example
{
    /** @var class-string<ExampleInterface> */
	public $className;
    
    /**
     * @param class-string<ExampleInterface> $className
     */
    function __construct(string $className)
    {
    	$this->className = $className;
    }
}

interface ExampleInterface {}
Psalm output (using commit 6419788):

ERROR: ImpurePropertyAssignment - 16:6 - Cannot store a reference to an externally-mutable object inside an immutable object – consider using __clone

@weirdan weirdan added the bug label Jul 3, 2020
@muglug muglug closed this as completed in 3d0a8c4 Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants