File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments