Skip to content

Commit c899542

Browse files
feat(view): add the shared comparison captions to ViewMessage and the capture guidance to DbMessage, so adapters stop carrying those literals. (#56)
1 parent 2d77422 commit c899542

48 files changed

Lines changed: 611 additions & 443 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"ext-intl": "*",
2525
"ext-mbstring": "*",
2626
"ui-awesome/html": "^0.6",
27-
"ui-awesome/html-core-component": "^0.4",
27+
"ui-awesome/html-core-component": "^0.5@dev",
2828
"ui-awesome/html-helper": "^0.7",
2929
"ui-awesome/html-interop": "^0.4",
3030
"ui-awesome/html-mixin": "^0.8.2",

‎src/Collector/CollectorCoordinator.php‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ public function capture(RequestSummary $summary): DebugSnapshot
8787
}
8888
}
8989

90-
return new DebugSnapshot(
91-
$summary,
92-
$panels,
93-
$failures,
94-
);
90+
return new DebugSnapshot($summary, $panels, $failures);
9591
}
9692

9793
/**

‎src/Comparison/SummaryMetricComparison.php‎

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,9 @@ private static function formatNumber(float|int $value, string $unit, int $precis
133133
*
134134
* @return self Metric comparison for the two counters.
135135
*/
136-
private static function integerMetric(
137-
string $label,
138-
int $baseline,
139-
int $target,
140-
string|null $panelId = null,
141-
): self {
142-
return self::numericMetric(
143-
$label,
144-
$baseline,
145-
$target,
146-
1,
147-
'',
148-
$panelId,
149-
0,
150-
);
136+
private static function integerMetric(string $label, int $baseline, int $target, string|null $panelId = null): self
137+
{
138+
return self::numericMetric($label, $baseline, $target, 1, '', $panelId, 0);
151139
}
152140

153141
/**
@@ -181,15 +169,7 @@ private static function nullableFloatMetric(
181169
);
182170
}
183171

184-
return self::numericMetric(
185-
$label,
186-
$baseline,
187-
$target,
188-
$scale,
189-
$unit,
190-
$panelId,
191-
2,
192-
);
172+
return self::numericMetric($label, $baseline, $target, $scale, $unit, $panelId, 2);
193173
}
194174

195175
/**

‎src/Helper/SensitiveDataRedactor.php‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,7 @@ public static function redact(
155155

156156
[$keyMap, $prefixes, $patterns] = self::rules($sensitiveKeys, $sensitiveKeyPrefixes, $sensitiveKeyPatterns);
157157

158-
return self::walk(
159-
$value,
160-
$keyMap,
161-
$prefixes,
162-
$patterns,
163-
0,
164-
$nodes,
165-
);
158+
return self::walk($value, $keyMap, $prefixes, $patterns, 0, $nodes);
166159
}
167160

168161
/**

‎src/Helper/Trace.php‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ private function __construct(private Closure|string|false $template, private arr
3737
*/
3838
public static function create(): self
3939
{
40-
return new self(
41-
self::DEFAULT_TEMPLATE,
42-
[],
43-
);
40+
return new self(self::DEFAULT_TEMPLATE, []);
4441
}
4542

4643
/**
@@ -69,6 +66,7 @@ public function render(array $frame): string
6966
}
7067

7168
$file = $this->mapPath(str_replace('\\', '/', $file));
69+
7270
$template = $this->template;
7371

7472
if ($template === false) {
@@ -122,10 +120,7 @@ public function withPathMappings(array $pathMappings): self
122120
$normalized[self::normalizePrefix((string) $remote)] = self::normalizePrefix($target);
123121
}
124122

125-
return new self(
126-
template: $this->template,
127-
pathMappings: $normalized,
128-
);
123+
return new self(template: $this->template, pathMappings: $normalized);
129124
}
130125

131126
/**
@@ -140,10 +135,7 @@ public function withPathMappings(array $pathMappings): self
140135
*/
141136
public function withTemplate(Closure|string|false $template): self
142137
{
143-
return new self(
144-
template: $template,
145-
pathMappings: $this->pathMappings,
146-
);
138+
return new self(template: $template, pathMappings: $this->pathMappings);
147139
}
148140

149141
/**

‎src/Panel/Asset/AssetPanel.php‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ final class AssetPanel extends Panel
3939
*/
4040
public function present(array $data): PanelView
4141
{
42-
$snapshot = AssetSnapshot::fromArray(
43-
$data,
44-
'$.asset',
45-
);
42+
$snapshot = AssetSnapshot::fromArray($data, '$.asset');
4643

4744
$bundles = $snapshot->bundles();
4845
$vite = $snapshot->vite();

‎src/Panel/Config/ConfigSnapshot.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public function data(): array
2323
return $this->values();
2424
}
2525

26+
/**
27+
* Returns the key under which the configuration payload is stored.
28+
*
29+
* @return string Payload key.
30+
*/
2631
protected static function payloadKey(): string
2732
{
2833
return 'data';

‎src/Panel/Db/DbMessage.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
*/
1010
enum DbMessage: string
1111
{
12+
/**
13+
* Guidance of the empty state, naming the profiler the adapter must wire so statements are captured.
14+
*
15+
* Format: "Configure the development connection with %s. ..."
16+
*/
17+
case CAPTURE_GUIDANCE = 'Configure the development connection with %s. Rows are shown only when the driver '
18+
. 'reports them. After a redirect, open the previous request from History.';
19+
1220
/**
1321
* Header of the column counting how many times the exact same statement ran.
1422
*/

‎src/Panel/Event/EventInspection.php‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public static function fromArray(mixed $data, string $path): self
5757

5858
foreach ($payload->map('context') as $key => $value) {
5959
if (!is_string($value) || strlen($value) > 2048 || strlen($key) > 128) {
60-
throw HydrationException::at("{$path}.context.{$key}", 'bounded text');
60+
throw HydrationException::at(
61+
"{$path}.context.{$key}",
62+
'bounded text',
63+
);
6164
}
6265

6366
$context[$key] = $value;
@@ -67,7 +70,10 @@ public static function fromArray(mixed $data, string $path): self
6770

6871
foreach ($payload->list('trace') as $index => $value) {
6972
if (!is_string($value) || strlen($value) > 2048) {
70-
throw HydrationException::at("{$path}.trace[{$index}]", 'bounded text');
73+
throw HydrationException::at(
74+
"{$path}.trace[{$index}]",
75+
'bounded text',
76+
);
7177
}
7278

7379
$trace[] = $value;

‎src/Panel/Mail/MailEntry.php‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ private function __construct(
7979
*/
8080
public static function create(string $from, array $to, string $subject, bool $isSuccessful): self
8181
{
82-
return new self(
83-
$from,
84-
$to,
85-
$subject,
86-
$isSuccessful,
87-
);
82+
return new self($from, $to, $subject, $isSuccessful);
8883
}
8984

9085
/**

0 commit comments

Comments
 (0)