File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ function throwable_decode($json)
57
57
58
58
array_pop ($ properties );
59
59
60
+ $ class = new ReflectionClass ($ json ['class ' ]);
60
61
$ throwable = new $ json ['class ' ]();
61
62
foreach ($ properties as $ key ) {
62
- if (!( new ReflectionClass ( $ json [ ' class ' ])) ->hasProperty ($ key )) {
63
+ if (!$ class ->hasProperty ($ key )) {
63
64
continue ;
64
65
}
65
66
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace WyriHaximus \Tests ;
4
+
5
+ final class MissingAttributes
6
+ {
7
+ public $ message ;
8
+ }
Original file line number Diff line number Diff line change @@ -27,4 +27,21 @@ public function test()
27
27
self ::assertSame ([], $ exception ->getTrace ());
28
28
self ::assertSame ('whoops ' , $ exception ->getMessage ());
29
29
}
30
+
31
+ public function testWithMissingAttributes ()
32
+ {
33
+ $ json = [
34
+ 'message ' => 'whoops ' ,
35
+ 'code ' => 13 ,
36
+ 'file ' => __FILE__ ,
37
+ 'line ' => 0 ,
38
+ 'trace ' => [],
39
+ 'class ' => 'WyriHaximus\Tests\MissingAttributes ' ,
40
+ ];
41
+
42
+ /** @var MissingAttributes $exception */
43
+ $ exception = WyriHaximus \throwable_decode ($ json );
44
+ self ::assertSame ('whoops ' , $ exception ->message );
45
+ self ::assertFalse (isset ($ exception ->code ));
46
+ }
30
47
}
You can’t perform that action at this time.
0 commit comments