File tree 3 files changed +16
-4
lines changed
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## Unreleased
9
9
10
+ ## 6.6.4
11
+
12
+ ### Fixed
13
+
14
+ - Fix conversion of ` Enum::fromKey() ` to native enum
15
+
10
16
## 6.6.3
11
17
12
18
### Fixed
Original file line number Diff line number Diff line change 4
4
5
5
use BenSampo \Enum \Enum ;
6
6
use BenSampo \Enum \Tests \Enums \UserType ;
7
+ use Illuminate \Support \Arr ;
7
8
use PhpParser \Node ;
8
9
use PhpParser \Node \Arg ;
9
10
use PhpParser \Node \Expr ;
41
42
use PhpParser \Node \Param ;
42
43
use PhpParser \Node \Scalar \Encapsed ;
43
44
use PhpParser \Node \Scalar \EncapsedStringPart ;
44
- use PhpParser \Node \Scalar \LNumber ;
45
45
use PhpParser \Node \Stmt \Case_ ;
46
46
use PhpParser \Node \Stmt \Return_ ;
47
47
use PhpParser \Node \Stmt \Switch_ ;
@@ -291,7 +291,13 @@ protected function refactorFromKey(StaticCall $call): ?Node
291
291
],
292
292
);
293
293
294
- return new ArrayDimFetch ($ arrayMatching , new LNumber (0 ));
294
+ return new StaticCall (
295
+ new Name (Arr::class),
296
+ 'first ' ,
297
+ [
298
+ new Arg ($ arrayMatching ),
299
+ ],
300
+ );
295
301
};
296
302
297
303
if ($ call ->isFirstClassCallable ()) {
Original file line number Diff line number Diff line change @@ -9,5 +9,5 @@ UserType::fromKey(...);
9
9
10
10
use BenSampo \Enum \Tests \Enums \UserType ;
11
11
12
- array_filter (UserType::cases (), fn (UserType $ userType ): bool => $ userType ->name === 'foo ' )[ 0 ] ;
13
- static fn (string $ key ): UserType => array_filter (UserType::cases (), fn (UserType $ userType ): bool => $ userType ->name === $ key )[ 0 ] ;
12
+ Illuminate \ Support \Arr:: first ( array_filter (UserType::cases (), fn (UserType $ userType ): bool => $ userType ->name === 'foo ' )) ;
13
+ static fn (string $ key ): UserType => Illuminate \ Support \Arr:: first ( array_filter (UserType::cases (), fn (UserType $ userType ): bool => $ userType ->name === $ key )) ;
You can’t perform that action at this time.
0 commit comments