Skip to content

Commit c280e48

Browse files
committed
Only assign values properties to properties when they exist
1 parent b057013 commit c280e48

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/functions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace WyriHaximus;
44

55
use Exception;
6+
use ReflectionClass;
67
use ReflectionProperty;
78
use Throwable;
89

@@ -58,6 +59,10 @@ function throwable_decode($json)
5859

5960
$throwable = new $json['class']();
6061
foreach ($properties as $key) {
62+
if (!(new ReflectionClass($json['class']))->hasProperty($key)) {
63+
continue;
64+
}
65+
6166
$property = new ReflectionProperty($json['class'], $key);
6267
$property->setAccessible(true);
6368
$property->setValue($throwable, $json[$key]);

0 commit comments

Comments
 (0)