Skip to content

Commit

Permalink
Merge pull request #92 from clue-labs/trace
Browse files Browse the repository at this point in the history
Avoid PHP warnings due to lack of args in exception trace on PHP 7.4
  • Loading branch information
clue authored Jun 15, 2020
2 parents 319f833 + bbc0e89 commit 5b7efb2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,19 @@ function (Exception $e) use ($uri, $deferred) {
$r = new \ReflectionProperty('Exception', 'trace');
$r->setAccessible(true);
$trace = $r->getValue($e);

// Exception trace arguments are not available on some PHP 7.4 installs
// @codeCoverageIgnoreStart
foreach ($trace as &$one) {
foreach ($one['args'] as &$arg) {
if ($arg instanceof \Closure) {
$arg = 'Object(' . get_class($arg) . ')';
if (isset($one['args'])) {
foreach ($one['args'] as &$arg) {
if ($arg instanceof \Closure) {
$arg = 'Object(' . \get_class($arg) . ')';
}
}
}
}
// @codeCoverageIgnoreEnd
$r->setValue($e, $trace);
}
);
Expand Down

0 comments on commit 5b7efb2

Please sign in to comment.