From e594d088fb51bf94bb4548cd984e28c65d663e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 10 Jun 2020 12:46:46 +0200 Subject: [PATCH] Avoid PHP warnings due to lack of args in exception trace on PHP 7.4 --- src/ProxyConnector.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ProxyConnector.php b/src/ProxyConnector.php index 2a87f4e..020e12a 100644 --- a/src/ProxyConnector.php +++ b/src/ProxyConnector.php @@ -253,13 +253,19 @@ public function connect($uri) $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); });