Skip to content

Commit

Permalink
Minor fixes/tweaks - Constants: collect isFinal / visibility, Emailer…
Browse files Browse the repository at this point in the history
… plugin... error summary.. error may not have email stats
  • Loading branch information
bkdotcom committed Apr 25, 2023
1 parent 888e1de commit cb75f76
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/Debug/Abstraction/AbstractObjectConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand Down
10 changes: 9 additions & 1 deletion src/Debug/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
1 change: 1 addition & 0 deletions src/Debug/Dump/Html/HtmlObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
11 changes: 9 additions & 2 deletions src/ErrorHandler/Plugin/Emailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
16 changes: 14 additions & 2 deletions tests/Debug/Type/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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' => '<li class="m_log"><div class="t_object" data-accessible="public"><span class="t_const" title="The most important meal
Expand Down Expand Up @@ -156,18 +162,24 @@ public static function providerTestMethod()
'BREAKFAST' => array(
'attributes' => array(),
'desc' => null,
'isFinal' => false,
'value' => 'breakfast',
'visibility' => 'public',
),
'LUNCH' => array(
'attributes' => array(),
'desc' => null,
'isFinal' => false,
'value' => 'lunch',
'visibility' => 'public',
),
'DINNER' => array(
'attributes' => array(),
'desc' => null,
'isFinal' => false,
'value' => 'dinner',
)
'visibility' => 'public',
),
), $abs['cases']);
},
'html' => '<li class="m_log"><div class="t_object" data-accessible="public"><span class="t_const"><span class="classname"><span class="namespace">bdk\Test\Debug\Fixture\Enum\</span>MealsBacked</span><span class="t_operator">::</span><span class="t_identifier">BREAKFAST</span></span>
Expand Down

0 comments on commit cb75f76

Please sign in to comment.