1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00
psalm/docs/running_psalm/issues/ImpureByReferenceAssignment.md

31 lines
393 B
Markdown
Raw Normal View History

2020-03-19 17:32:49 +01:00
# ImpureByReferenceAssignment
Emitted when assigning a passed-by-reference variable inside a function or method marked as mutation-free.
```php
2020-03-21 00:13:46 +01:00
<?php
2020-03-19 17:32:49 +01:00
/**
* @psalm-pure
*/
function foo(string &$a): string {
$a = "B";
return $a;
}
```
2020-03-21 05:39:00 +01:00
## How to fix
Just remove the mutating assignment:
```php
<?php
/**
* @psalm-pure
*/
function foo(string &$a): string {
return $a;
}
```