From cb75f76953016201ff3791d445587692a1bf8afc Mon Sep 17 00:00:00 2001 From: Brad Kent Date: Tue, 25 Apr 2023 09:50:10 -0500 Subject: [PATCH] Minor fixes/tweaks - Constants: collect isFinal / visibility, Emailer plugin... error summary.. error may not have email stats --- .../Abstraction/AbstractObjectConstants.php | 2 ++ src/Debug/Data.php | 10 +++++++++- src/Debug/Dump/Html/HtmlObject.php | 1 + src/ErrorHandler/Plugin/Emailer.php | 11 +++++++++-- tests/Debug/Type/EnumTest.php | 16 ++++++++++++++-- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/Debug/Abstraction/AbstractObjectConstants.php b/src/Debug/Abstraction/AbstractObjectConstants.php index cb885dc4..fa37a230 100644 --- a/src/Debug/Abstraction/AbstractObjectConstants.php +++ b/src/Debug/Abstraction/AbstractObjectConstants.php @@ -168,9 +168,11 @@ private function getCaseRefInfo(ReflectionEnumUnitCase $refCase) 'desc' => $this->phpDocCollect ? $this->helper->getPhpDocVar($refCase)['desc'] : null, + 'isFinal' => $refCase->isFinal(), 'value' => $refCase instanceof ReflectionEnumBackedCase ? $refCase->getBackingValue() : null, + 'visibility' => $this->helper->getVisibility($refCase), ); } diff --git a/src/Debug/Data.php b/src/Debug/Data.php index ea263d3d..3ff6d3a7 100644 --- a/src/Debug/Data.php +++ b/src/Debug/Data.php @@ -88,11 +88,19 @@ public function set($path, $value = null) $this->setLogDest($value); return; } - if (\is_string($path)) { + $setLogDest = true; + if (\is_string($path) || \func_num_args() === 2) { + $key = \is_array($path) + ? $path[0] + : $path; + $setLogDest = \in_array($key, array('alerts', 'log', 'logSummary'), true); $this->arrayUtil->pathSet($this->data, $path, $value); } elseif (\is_array($path)) { $this->data = \array_merge($this->data, $path); } + if ($setLogDest === false) { + return; + } if (!$this->data['log']) { $this->debug->methodGroup->reset('main'); } diff --git a/src/Debug/Dump/Html/HtmlObject.php b/src/Debug/Dump/Html/HtmlObject.php index 45541a17..632f7fa8 100644 --- a/src/Debug/Dump/Html/HtmlObject.php +++ b/src/Debug/Dump/Html/HtmlObject.php @@ -188,6 +188,7 @@ protected function dumpClassname(Abstraction $abs) $title = $phpDocOutput ? \trim($abs['phpDoc']['summary'] . "\n\n" . $abs['phpDoc']['desc']) : null; + $title = $title ?: null; if (\in_array('UnitEnum', $abs['implements'], true)) { return $this->html->buildTag( 'span', diff --git a/src/ErrorHandler/Plugin/Emailer.php b/src/ErrorHandler/Plugin/Emailer.php index 1f5b0a45..e567eb74 100644 --- a/src/ErrorHandler/Plugin/Emailer.php +++ b/src/ErrorHandler/Plugin/Emailer.php @@ -235,13 +235,20 @@ protected function buildBodySummary($errors) { $emailBody = ''; foreach ($errors as $errStats) { - $dateLastEmailed = \date($this->cfg['dateTimeFmt'], $errStats['email']['timestamp']) ?: '??'; + $countSinceLine = isset($errStats['email']) + ? \sprintf( + 'Has occured %s times since %s' . "\n", + $errStats['email']['countSince'], + \date($this->cfg['dateTimeFmt'], $errStats['email']['timestamp']) + ) + : ''; $info = $errStats['info']; $emailBody .= '' . 'File: ' . $info['file'] . "\n" . 'Line: ' . $info['line'] . "\n" . 'Error: ' . Error::typeStr($info['type']) . ': ' . $info['message'] . "\n" - . 'Has occured ' . $errStats['email']['countSince'] . ' times since ' . $dateLastEmailed . "\n\n"; + . $countSinceLine + . "\n"; } return $emailBody; } diff --git a/tests/Debug/Type/EnumTest.php b/tests/Debug/Type/EnumTest.php index 7305d54f..0b4e9fe8 100644 --- a/tests/Debug/Type/EnumTest.php +++ b/tests/Debug/Type/EnumTest.php @@ -43,7 +43,9 @@ public static function providerTestMethod() 'BREAKFAST' => array( 'attributes' => array(), 'desc' => 'The most important meal', + 'isFinal' => false, 'value' => null, + 'visibility' => 'public', ), 'LUNCH' => array( 'attributes' => array( @@ -53,13 +55,17 @@ public static function providerTestMethod() ), ), 'desc' => null, + 'isFinal' => false, 'value' => null, + 'visibility' => 'public', ), 'DINNER' => array( 'attributes' => array(), 'desc' => null, + 'isFinal' => false, 'value' => null, - ) + 'visibility' => 'public', + ), ), $abs['cases']); }, 'html' => '
  • bdk\Test\Debug\Fixture\Enum\MealsBacked::BREAKFAST