From ab5a04bade6ace846c4cef27a038bee3be9f446b Mon Sep 17 00:00:00 2001 From: yaozm Date: Tue, 23 Apr 2024 11:00:29 +0800 Subject: [PATCH] refactor(debug): improve debug info handling - Removed unused import - Refactored __debugInfo method to use mergeDebugInfo function for better handling of debug info --- src/Concerns/ConcreteMagic.php | 5 +---- src/Concerns/WithDumpable.php | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Concerns/ConcreteMagic.php b/src/Concerns/ConcreteMagic.php index f7f7d09..38a3cdb 100644 --- a/src/Concerns/ConcreteMagic.php +++ b/src/Concerns/ConcreteMagic.php @@ -13,7 +13,6 @@ namespace Guanguans\SoarPHP\Concerns; use Guanguans\SoarPHP\Exceptions\InvalidOptionException; -use Symfony\Component\VarDumper\VarDumper; /** * @mixin \Guanguans\SoarPHP\Soar @@ -52,9 +51,7 @@ public function __wakeup(): void public function __debugInfo(): array { - $debugInfo = ['commandLine' => (string) $this]; - - return class_exists(VarDumper::class) ? $debugInfo : get_object_vars($this) + $debugInfo; + return $this->mergeDebugInfo(['commandLine' => (string) $this]); } /** diff --git a/src/Concerns/WithDumpable.php b/src/Concerns/WithDumpable.php index b69f7ad..0087ce6 100644 --- a/src/Concerns/WithDumpable.php +++ b/src/Concerns/WithDumpable.php @@ -46,4 +46,9 @@ public function dump(...$args): self return $this; } + + private function mergeDebugInfo(array $debugInfo): array + { + return class_exists(VarDumper::class) ? $debugInfo : get_object_vars($this) + $debugInfo; + } }