diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ff9ec2..cfbd0b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Released Notes +## v3.3.1 - (2024-08-03) + +### Fixed + +- Fixed render solution in CLI mode + +-------------------------------------------------------------------------- + ## v3.3.0 - (2024-07-17) ### Added diff --git a/src/ModernPHPException.php b/src/ModernPHPException.php index e53dd94..bfec527 100644 --- a/src/ModernPHPException.php +++ b/src/ModernPHPException.php @@ -3,19 +3,13 @@ namespace ModernPHPException; use Symfony\Component\Yaml\Yaml; -use ModernPHPException\Trait\{ - RenderTrait, - HelpersTrait, - HandlerAssetsTrait -}; +use ModernPHPException\Trait\{RenderTrait, HelpersTrait, HandlerAssetsTrait}; class ModernPHPException { - use HelpersTrait; - use HandlerAssetsTrait; - use RenderTrait; + use HelpersTrait, HandlerAssetsTrait, RenderTrait; - public const VERSION = "3.3.0"; + public const VERSION = "3.3.1"; /** * @var Bench diff --git a/src/Trait/RenderTrait.php b/src/Trait/RenderTrait.php index a40466a..ecb97df 100644 --- a/src/Trait/RenderTrait.php +++ b/src/Trait/RenderTrait.php @@ -3,8 +3,7 @@ namespace ModernPHPException\Trait; use ModernPHPException\Console\CliMessage; -use ModernPHPException\Occurrences; -use ModernPHPException\Solution; +use ModernPHPException\{Occurrences, Solution}; use ModernPHPException\Resources\{CpuUsage, HtmlTag, MemoryUsage}; trait RenderTrait @@ -74,10 +73,7 @@ protected function registerOccurrence(): void */ private function render(): never { - if (ob_get_contents()) { - ob_end_clean(); - } - + if (ob_get_contents()) ob_end_clean(); $this->renderCli(); if ( @@ -90,9 +86,7 @@ private function render(): never $this->renderJson(); } - if ($this->config['production_mode'] === true) { - $this->productionMode(); - } + if ($this->config['production_mode'] === true) $this->productionMode(); // Don't erase `$resources` variable $resources = $this->loadResources(); @@ -116,9 +110,7 @@ private function render(): never private function filterTrace(array $trace): array { foreach ($trace as $key => $value) { - if (!array_key_exists('file', $value) && !array_key_exists('line', $value)) { - unset($trace[$key]); - } + if (!array_key_exists('file', $value) && !array_key_exists('line', $value)) unset($trace[$key]); } return $trace; @@ -131,13 +123,8 @@ private function filterTrace(array $trace): array */ private function loadResources(): array { - if ($this->config['title'] !== "") { - $this->title = $this->config['title']; - } - - if ($this->config['dark_mode'] === true) { - $this->useDarkTheme(); - } + if ($this->config['title'] !== "") $this->title = $this->config['title']; + if ($this->config['dark_mode'] === true) $this->useDarkTheme(); $list_occurrences = null; $cpu_usage = CpuUsage::getServerLoad(); @@ -298,15 +285,14 @@ private function renderSolutionCli(): void if (method_exists($exception, "getSolution")) { $exception->getSolution(); - $solution = new Solution(); if (!empty($this->solution->getDescription()) || $this->solution->getDescription() != "") { - $this->success($solution->getTitle())->print(); + CliMessage::success($solution->getTitle())->print(); echo " : "; - $this->success($solution->getDescription())->print()->break(true); + CliMessage::success($solution->getDescription())->print()->break(true); } else { - $this->success($solution->getTitle())->print()->break(true); + CliMessage::success($solution->getTitle())->print()->break(true); } } }