Skip to content

Commit 1294292

Browse files
committed
Update UPGRADING-v5.md
1 parent 4dd82ae commit 1294292

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

UPGRADING-v5.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
## Functions BC
22

3-
All collection functions with `$callback`/`$predicate` params does not allow key as second parameter anymore.
4-
To use key in the map, filter and other collection functions use *KV combinators:
3+
- All collection functions with `$callback`/`$predicate` params does not allow key as second parameter anymore.
4+
To use key in the map, filter and other collection functions use *KV combinators.
5+
Each collection function with `$callback`/`$predicate` has *KV version:
56
```diff
67
- \Fp\Collection\map(fn($value, $key) => new Row(id: $key, data: $value));
78
+ \Fp\Collection\mapKV(fn($key, $value) => new Row(id: $key, data: $value));
89
```
9-
Each collection function with `$callback`/`$predicate` has *KV version.
10+
11+
- Parameter `$preserveKeys` of `Fp\Collection\filter` has been removed. Type of input array will be preserved:
12+
```diff
13+
- \Fp\Collection\filter(['a' => 1, 'b' => 2], fn($value) => $value !== 1, preserveKeys: true); // result is ['b' => 2]
14+
+ \Fp\Collection\filter(['a' => 1, 'b' => 2], fn($value) => $value !== 1); // result is ['b' => 2]
15+
- \Fp\Collection\filter([1, 2], fn($value) => $value !== 1, preserveKeys: true); // result is [2]
16+
+ \Fp\Collection\filter([1, 2], fn($value) => $value !== 1); // result is [2]
17+
```
1018

1119
- `Fp\Collection\existsOf` has been removed. Use `Fp\Collection\exists` instead:
1220
```diff
@@ -80,6 +88,21 @@ Each collection function with `$callback`/`$predicate` has *KV version.
8088
+ \Fp\Evidence\proveNonEmptyArray(getMixed(), vType: of(Foo::class));
8189
```
8290

91+
- `Fp\Json\jsonDecode` moved to `Fp\Util\jsonDecode`:
92+
```diff
93+
- \Fp\Json\jsonDecode('[1,2,3]');
94+
+ \Fp\Util\jsonDecode('[1,2,3]');
95+
```
96+
97+
- `Fp\String\regExpMatch` moved to `Fp\Util\regExpMatch`:
98+
```diff
99+
- \Fp\String\regExpMatch('/[a-z]+(?<num>[0-9]+)/', 'aa1123');
100+
+ \Fp\Util\regExpMatch('/[a-z]+(?<num>[0-9]+)/', 'aa1123');
101+
```
102+
103+
- `Fp\Reflection\getReflectionClass` has been removed without replacement.
104+
- `Fp\Reflection\getReflectionProperty` has been removed without replacement.
105+
83106
## Option BC
84107
- `Fp\Functional\Option\Option::filterOf` has been removed. Use `Fp\Functional\Option\Option::flatMap` and `Fp\Evidence\of`:
85108
```diff

0 commit comments

Comments
 (0)