Skip to content

Commit 0c6ed17

Browse files
committed
Node about removing psalm-pure, psalm-immutable
1 parent 2b5e8ea commit 0c6ed17

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

UPGRADING-v5.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
## Remove psalm-pure and psalm-immutable
2+
3+
Before v5 all data structures and most function was pure.
4+
Since v5 `@psalm-pure` and `@psalm-immutable` has been removed.
5+
It has many false positives, and it's to difficult use in the real applications.
6+
7+
Some examples with useful code (but with false positives):
8+
- https://psalm.dev/r/e58c340477
9+
- https://psalm.dev/r/de37ebb8ed
10+
- https://psalm.dev/r/627b50d716
11+
12+
Discussion of the problem: https://github.com/vimeo/psalm/issues/8116
13+
14+
This code is invalid since v5:
15+
```php
16+
/**
17+
* @param ArrayList<int> $list
18+
* @return ArrayList<int>
19+
* @psalm-pure
20+
*/
21+
function pureFn(ArrayList $list): ArrayList
22+
{
23+
// ERROR: ImpureMethodCall
24+
return $list->map(fn($i) => $i + 2);
25+
}
26+
```
27+
28+
Removing `@psalm-pure` from the `pureFn` fix that problem.
29+
130
## Functions BC
231

332
- All collection functions with `$callback`/`$predicate` params does not allow key as second parameter anymore.

0 commit comments

Comments
 (0)