Skip to content

Commit e68d3c9

Browse files
committed
tweak html table... don't need text-right class
1 parent bdc8074 commit e68d3c9

12 files changed

Lines changed: 82 additions & 83 deletions

File tree

src/Debug/Dump/Html/Table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected function buildHeader()
201201
$labels = \array_map([$this, 'buildHeaderLabel'], $this->options['tableInfo']['columns']);
202202
$keyLabel = $this->options['tableInfo']['commonRowInfo']['keyOutput']
203203
? ($this->options['tableInfo']['indexLabel']
204-
? '<th class="text-right">' . $this->options['tableInfo']['indexLabel'] . '</th>'
204+
? '<th>' . $this->options['tableInfo']['indexLabel'] . '</th>'
205205
: '<th>&nbsp;</th>')
206206
: '';
207207
return '<thead>' . "\n"
@@ -316,7 +316,7 @@ private function buildRowKey($rowKey)
316316
return $this->debug->html->buildTag(
317317
'th',
318318
$this->debug->arrayUtil->mergeDeep($rowKeyParsed['attribs'], array(
319-
'class' => ['t_key', 'text-right'],
319+
'class' => ['t_key'],
320320
'scope' => 'row',
321321
)),
322322
$rowKeyParsed['innerhtml']

src/Debug/Utility/ArrayUtilHelperTrait.php

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,32 +92,28 @@ private static function assertCountable($value, array $path, $method)
9292
private static function diffDeepWalk(array $array, array $array2)
9393
{
9494
$diff = array();
95-
$allInt = true;
96-
\array_walk(
97-
$array,
98-
/**
99-
* @param array-key $key
100-
*/
101-
static function ($value, $key) use (&$allInt, &$diff, $array2) {
102-
$incl = false;
103-
if (\array_key_exists($key, $array2) === false) {
104-
$incl = true;
105-
} elseif (self::isNonMergeable($value) === false && self::isNonMergeable($array2[$key]) === false) {
106-
$value = self::diffDeep($value, $array2[$key]);
107-
$incl = !empty($value);
108-
} elseif (\is_int($key)) {
109-
$foundIndex = \array_search($value, $array2, true);
110-
$incl = $foundIndex === false || \is_int($foundIndex) === false;
111-
} elseif ($value !== $array2[$key]) {
112-
// not in $array2 or different value
113-
$incl = true;
114-
}
115-
if ($incl) {
116-
$allInt = $allInt && \is_int($key);
117-
$diff[$key] = $value;
118-
}
95+
$allInt = true; // true if all kept keys are int
96+
$walkFunc = static function ($value, $key) use (&$allInt, &$diff, $array2) {
97+
$incl = false;
98+
if (\array_key_exists($key, $array2) === false) {
99+
$incl = true;
100+
} elseif (self::isMergeable($value) && self::isMergeable($array2[$key])) {
101+
$value = self::diffDeep($value, $array2[$key]);
102+
$incl = !empty($value);
103+
} elseif (\is_int($key)) {
104+
// integer key... keep value if not in array2 (or if in array2, but with string key / not a list)
105+
$foundIndex = \array_search($value, $array2, true);
106+
$incl = $foundIndex === false || \is_int($foundIndex) === false;
107+
} elseif ($value !== $array2[$key]) {
108+
// different value in array2
109+
$incl = true;
119110
}
120-
);
111+
if ($incl) {
112+
$allInt = $allInt && \is_int($key);
113+
$diff[$key] = $value;
114+
}
115+
};
116+
\array_walk($array, $walkFunc);
121117
if ($allInt) {
122118
$diff = \array_values($diff);
123119
}
@@ -144,17 +140,17 @@ private static function diffStrictWalk(array $array, array $array2)
144140
}
145141

146142
/**
147-
* Check that value is not an array
143+
* Check that value is an array (but not a "callable")
148144
*
149145
* @param mixed $value Value to test
150146
*
151147
* @return bool
152148
*
153-
* @psalm-assert-if-false array $value
149+
* @psalm-assert-if-true array $value
154150
*/
155-
private static function isNonMergeable($value)
151+
private static function isMergeable($value)
156152
{
157-
return \is_array($value) === false || Php::isCallable($value, Php::IS_CALLABLE_ARRAY_ONLY);
153+
return \is_array($value) && Php::isCallable($value, Php::IS_CALLABLE_ARRAY_ONLY) === false;
158154
}
159155

160156
/**
@@ -188,7 +184,7 @@ private static function mergeDeepWalk(array $arrayDef, array $array2)
188184
* @param array-key $key
189185
*/
190186
static function ($value, $key) use (&$arrayDef) {
191-
if (self::isNonMergeable($value)) {
187+
if (self::isMergeable($value) === false) {
192188
// not array or appears to be a callable
193189
if (\is_int($key) === false) {
194190
$arrayDef[$key] = $value;
@@ -198,7 +194,7 @@ static function ($value, $key) use (&$arrayDef) {
198194
}
199195
return;
200196
}
201-
if (isset($arrayDef[$key]) === false || self::isNonMergeable($arrayDef[$key])) {
197+
if (isset($arrayDef[$key]) === false || self::isMergeable($arrayDef[$key]) === false) {
202198
// default not set or can be overwritten without merge
203199
$arrayDef[$key] = $value;
204200
return;

src/Debug/css/Debug.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Debug/scss/_table.scss

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ table {
99
padding-top: 2px;
1010
text-align: left;
1111
}
12+
tr[data-toggle] {
13+
cursor: default;
14+
&:hover {
15+
color: var(--color-table-hover-fg);
16+
background-color: var(--color-table-hover-bg);
17+
}
18+
}
1219
th,
1320
td {
1421
padding: 0 0.25em;
@@ -34,6 +41,9 @@ table {
3441
font-weight: bold;
3542
background-color: var(--color-table-th-bg);
3643
}
44+
th:first-child {
45+
text-align: right;
46+
}
3747
thead th {
3848
text-align: center;
3949
.classname {
@@ -43,13 +53,6 @@ table {
4353
&::after { content: ")"; }
4454
}
4555
}
46-
tr[data-toggle] {
47-
cursor: default;
48-
&:hover {
49-
color: var(--color-table-hover-fg);
50-
background-color: var(--color-table-hover-bg);
51-
}
52-
}
5356
tbody th.t_int,
5457
td[data-type-more=numeric],
5558
td.timestamp,

tests/Debug/Collector/DoctrineLoggerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function testOutput()
9898
<tr><th>&nbsp;</th><th scope="col">value</th><th scope="col">type</th></tr>
9999
</thead>
100100
<tbody>
101-
<tr><th class="t_key t_string text-right" scope="row">:datetime</th><td class="t_string">{$datetime}</td><td class="t_identifier" data-type-more="const" title="value: 2"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_STR</span></td></tr>
101+
<tr><th class="t_key t_string" scope="row">:datetime</th><td class="t_string">{$datetime}</td><td class="t_identifier" data-type-more="const" title="value: 2"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_STR</span></td></tr>
102102
</tbody>
103103
</table>
104104
</li>
@@ -132,12 +132,12 @@ public function testOutput()
132132
<tr><th>&nbsp;</th><th scope="col">value</th><th scope="col">type</th></tr>
133133
</thead>
134134
<tbody>
135-
<tr><th class="t_int t_key text-right" scope="row">0</th><td class="t_array"><span class="t_keyword">array</span><span class="t_punct">(</span>
135+
<tr><th class="t_int t_key" scope="row">0</th><td class="t_array"><span class="t_keyword">array</span><span class="t_punct">(</span>
136136
<ul class="array-inner list-unstyled">
137137
<li><span class="t_int t_key">0</span><span class="t_operator">=&gt;</span><span class="t_string">foo</span></li>
138138
<li><span class="t_int t_key">1</span><span class="t_operator">=&gt;</span><span class="t_string">bar</span></li>
139139
</ul><span class="t_punct">)</span></td><td class="t_identifier" data-type-more="const" title="value: 101"><span class="classname"><span class="namespace">Doctrine\DBAL\</span>Connection</span><span class="t_operator">::</span><span class="t_name">PARAM_INT_ARRAY</span></td></tr>
140-
<tr><th class="t_int t_key text-right" scope="row">1</th><td class="t_string">declined</td><td class="t_identifier" data-type-more="const" title="value: 2"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_STR</span></td></tr>
140+
<tr><th class="t_int t_key" scope="row">1</th><td class="t_string">declined</td><td class="t_identifier" data-type-more="const" title="value: 2"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_STR</span></td></tr>
141141
</tbody>
142142
</table>
143143
</li>

tests/Debug/Collector/DoctrineMiddlewareTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function testOutput()
108108
<tr><th>&nbsp;</th><th scope="col">value</th><th scope="col">type</th></tr>
109109
</thead>
110110
<tbody>
111-
<tr><th class="t_key t_string text-right" scope="row">:datetime</th><td class="t_string">{$datetime}</td>{$parameterTypeTd}</tr>
111+
<tr><th class="t_key t_string" scope="row">:datetime</th><td class="t_string">{$datetime}</td>{$parameterTypeTd}</tr>
112112
</tbody>
113113
</table>
114114
</li>
@@ -125,15 +125,15 @@ public function testOutput()
125125
self::assertStringMatchesFormatNormalized($select1expect, $output);
126126

127127
$params =\method_exists($statement, 'bindValue') && \is_int(\Doctrine\DBAL\ParameterType::STRING) === false
128-
? '<tr><th class="t_int t_key text-right" scope="row">1</th><td class="t_string">foo</td><td class="t_identifier" data-type-more="const" title="Represents the SQL INTEGER data type.
128+
? '<tr><th class="t_int t_key" scope="row">1</th><td class="t_string">foo</td><td class="t_identifier" data-type-more="const" title="Represents the SQL INTEGER data type.
129129
Statement parameter type."><span class="classname"><span class="namespace">Doctrine\DBAL\</span>ParameterType</span><span class="t_operator">::</span><span class="t_name">INTEGER</span></td></tr>
130-
<tr><th class="t_int t_key text-right" scope="row">2</th><td class="t_string">bar</td><td class="t_identifier" data-type-more="const" title="Represents the SQL INTEGER data type.
130+
<tr><th class="t_int t_key" scope="row">2</th><td class="t_string">bar</td><td class="t_identifier" data-type-more="const" title="Represents the SQL INTEGER data type.
131131
Statement parameter type."><span class="classname"><span class="namespace">Doctrine\DBAL\</span>ParameterType</span><span class="t_operator">::</span><span class="t_name">INTEGER</span></td></tr>
132-
<tr><th class="t_int t_key text-right" scope="row">3</th><td class="t_string">declined</td><td class="t_identifier" data-type-more="const" title="Represents the SQL CHAR, VARCHAR, or other string data type.
132+
<tr><th class="t_int t_key" scope="row">3</th><td class="t_string">declined</td><td class="t_identifier" data-type-more="const" title="Represents the SQL CHAR, VARCHAR, or other string data type.
133133
Statement parameter type."><span class="classname"><span class="namespace">Doctrine\DBAL\</span>ParameterType</span><span class="t_operator">::</span><span class="t_name">STRING</span></td></tr>'
134-
: '<tr><th class="t_int t_key text-right" scope="row">1</th><td class="t_string">foo</td><td class="t_identifier" data-type-more="const" title="value: 1"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_INT</span></td></tr>
135-
<tr><th class="t_int t_key text-right" scope="row">2</th><td class="t_string">bar</td><td class="t_identifier" data-type-more="const" title="value: 1"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_INT</span></td></tr>
136-
<tr><th class="t_int t_key text-right" scope="row">3</th><td class="t_string">declined</td><td class="t_identifier" data-type-more="const" title="value: 2"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_STR</span></td></tr>';
134+
: '<tr><th class="t_int t_key" scope="row">1</th><td class="t_string">foo</td><td class="t_identifier" data-type-more="const" title="value: 1"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_INT</span></td></tr>
135+
<tr><th class="t_int t_key" scope="row">2</th><td class="t_string">bar</td><td class="t_identifier" data-type-more="const" title="value: 1"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_INT</span></td></tr>
136+
<tr><th class="t_int t_key" scope="row">3</th><td class="t_string">declined</td><td class="t_identifier" data-type-more="const" title="value: 2"><span class="classname">PDO</span><span class="t_operator">::</span><span class="t_name">PARAM_STR</span></td></tr>';
137137
$select2expect = <<<EOD
138138
%A
139139
<li class="m_group" data-channel="general.Doctrine" data-icon="fa fa-database" id="statementInfo3">

tests/Debug/Plugin/Method/ProfileTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ public function testProfile()
137137
<tr><th>&nbsp;</th><th scope="col">calls</th><th scope="col">totalTime</th><th scope="col">ownTime</th></tr>
138138
</thead>
139139
<tbody>
140-
<tr><th class="t_identifier t_key text-right" data-type-more="method" scope="row"><span class="classname"><span class="namespace">bdk\Test\Debug\Plugin\Method\</span>ProfileTest</span><span class="t_operator">::</span><span class="t_name">a</span></th><td class="t_int">1</td><td class="t_float">%f</td><td class="t_float">%f</td></tr>
141-
<tr><th class="t_identifier t_key text-right" data-type-more="method" scope="row"><span class="classname"><span class="namespace">bdk\Test\Debug\Plugin\Method\</span>ProfileTest</span><span class="t_operator">::</span><span class="t_name">b</span></th><td class="t_int">1</td><td class="t_float">%f</td><td class="t_float">%f</td></tr>
142-
<tr><th class="t_identifier t_key text-right" data-type-more="method" scope="row"><span class="classname"><span class="namespace">bdk\Test\Debug\Plugin\Method\</span>ProfileTest</span><span class="t_operator">::</span><span class="t_name">c</span></th><td class="t_int">2</td><td class="t_float">%f</td><td class="t_float">%f</td></tr>
140+
<tr><th class="t_identifier t_key" data-type-more="method" scope="row"><span class="classname"><span class="namespace">bdk\Test\Debug\Plugin\Method\</span>ProfileTest</span><span class="t_operator">::</span><span class="t_name">a</span></th><td class="t_int">1</td><td class="t_float">%f</td><td class="t_float">%f</td></tr>
141+
<tr><th class="t_identifier t_key" data-type-more="method" scope="row"><span class="classname"><span class="namespace">bdk\Test\Debug\Plugin\Method\</span>ProfileTest</span><span class="t_operator">::</span><span class="t_name">b</span></th><td class="t_int">1</td><td class="t_float">%f</td><td class="t_float">%f</td></tr>
142+
<tr><th class="t_identifier t_key" data-type-more="method" scope="row"><span class="classname"><span class="namespace">bdk\Test\Debug\Plugin\Method\</span>ProfileTest</span><span class="t_operator">::</span><span class="t_name">c</span></th><td class="t_int">2</td><td class="t_float">%f</td><td class="t_float">%f</td></tr>
143143
</tbody>
144144
<tfoot>
145145
<tr><td>&nbsp;</td><td></td><td></td><td class="t_float">%f</td></tr>

0 commit comments

Comments
 (0)