From ca1e27b4bba6da85cb0249ab02528dda7edcf969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Noco=C5=84?= Date: Wed, 23 Aug 2023 11:36:19 +0200 Subject: [PATCH] Fixed error handling when InteractiveDebug is used outside Component class (#292) * [Composer] Disabled php-http/discovery plugin * Fixed error handling when InteractiveDebug is used outside Component class --- composer.json | 3 ++- src/lib/Core/Debug/InteractiveDebuggerTrait.php | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 24aecabe..3fd602ac 100644 --- a/composer.json +++ b/composer.json @@ -78,7 +78,8 @@ "bin": ["bin/ibexabehat", "bin/ibexareport"], "config": { "allow-plugins": { - "composer/package-versions-deprecated": true + "composer/package-versions-deprecated": true, + "php-http/discovery": false } } } diff --git a/src/lib/Core/Debug/InteractiveDebuggerTrait.php b/src/lib/Core/Debug/InteractiveDebuggerTrait.php index ca819792..81c0d4f1 100644 --- a/src/lib/Core/Debug/InteractiveDebuggerTrait.php +++ b/src/lib/Core/Debug/InteractiveDebuggerTrait.php @@ -83,9 +83,13 @@ private function getCallingComponent(): Component { $trace = debug_backtrace(); foreach ($trace as $traceLine) { - if ($traceLine['function'] === 'eval') { + if (!array_key_exists('function', $traceLine) || + $traceLine['function'] === 'eval' || + !array_key_exists('object', $traceLine) + ) { continue; } + $object = $traceLine['object']; if ($object instanceof Component) { return $object;