Skip to content

Commit

Permalink
refactor(debug): improve debug info handling
Browse files Browse the repository at this point in the history
- Removed unused import
- Refactored __debugInfo method to use mergeDebugInfo function for better handling of debug info
  • Loading branch information
guanguans committed Apr 23, 2024
1 parent 6e66c0f commit ab5a04b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/Concerns/ConcreteMagic.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace Guanguans\SoarPHP\Concerns;

use Guanguans\SoarPHP\Exceptions\InvalidOptionException;
use Symfony\Component\VarDumper\VarDumper;

/**
* @mixin \Guanguans\SoarPHP\Soar
Expand Down Expand Up @@ -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]);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Concerns/WithDumpable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit ab5a04b

Please sign in to comment.