Skip to content

Commit

Permalink
Use reflection to create exception on PHP 7 and use a fallback for PHP 5
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Feb 26, 2018
1 parent 14d64e1 commit bf30ba3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ function throwable_decode($json)

array_pop($properties);

if (PHP_MAJOR_VERSION === 7) {
$throwable = (new ReflectionClass($json['class']))->newInstanceWithoutConstructor();
}
$class = new ReflectionClass($json['class']);
$throwable = new $json['class']();
if (!isset($throwable)) {
$throwable = new $json['class']();
}
foreach ($properties as $key) {
if (!$class->hasProperty($key)) {
continue;
Expand Down

0 comments on commit bf30ba3

Please sign in to comment.