Skip to content

Commit 871b8f9

Browse files
committed
update
1 parent 14201a8 commit 871b8f9

3 files changed

Lines changed: 17 additions & 11 deletions

File tree

src/DebuggerTool.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public function getCacheTabPane(int $requestId, Request $request): string
628628
$total += $call->duration;
629629

630630
$html[] = '<tr>';
631-
$html[] = '<td>' . strtoupper($call->command) . ' ' . implode(' ', $call->arguments) . '</td>';
631+
$html[] = '<td>' . strtoupper($call->command) . ' ' . implode(' ', array_map(static fn($a) => is_scalar($a) ? (string) $a : '', $call->arguments)) . '</td>';
632632
$html[] = '<td>' . htmlspecialchars(is_string($call->result) ? $call->result : '') . '</td>';
633633
$html[] = '<td>' . sprintf('%.2f ms', $call->duration * 1000) . '</td>';
634634
$html[] = '</tr>';

src/Translator/TranslationCallAdder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ function ($matches) use (&$phpBlocks, &$echoBlocks, &$phpId) {
6868

6969
// Preserve leading and trailing whitespace
7070
preg_match('/^(\s*)(.*?)(\s*)$/s', $text, $whiteMatches);
71-
$leadingWhite = $whiteMatches[1];
72-
$trimmedText = $whiteMatches[2];
73-
$trailingWhite = $whiteMatches[3];
71+
$leadingWhite = $whiteMatches[1] ?? '';
72+
$trimmedText = $whiteMatches[2] ?? '';
73+
$trailingWhite = $whiteMatches[3] ?? '';
7474

7575
// Skip if no actual content or only a PHP echo placeholder
7676
if (!$trimmedText || preg_match('/^__PHP-ECHO__\d+$/', $trimmedText)) {
@@ -110,7 +110,7 @@ private function createTranslationBlock(string $text, array $echoBlocks): string
110110
function ($matches) use (&$params, $echoBlocks) {
111111
$echoBlock = $echoBlocks[$matches[1]];
112112
preg_match('/<\?php\s*e\((.*?)\);\s*\?>/', $echoBlock, $innerMatches);
113-
$params[] = $innerMatches[1];
113+
$params[] = $innerMatches[1] ?? '""';
114114
return '%s';
115115
},
116116
$text

src/TranslatorTool.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,13 @@ private function parsePotFile(string $potFile): array
485485
if (str_starts_with($line, '#:')) {
486486
$currentLocations[] = trim(substr($line, 2));
487487
} elseif (str_starts_with($line, 'msgid')) {
488-
$currentMsgid = [json_decode(substr(trim($line), 6))];
488+
$decoded = json_decode(substr(trim($line), 6));
489+
$currentMsgid = [is_string($decoded) ? $decoded : ''];
489490
// Check for multi-line msgid
490491
$j = $i + 1;
491492
while ($j < count($lines) && str_starts_with(trim($lines[$j]), '"')) {
492-
$currentMsgid[] = json_decode(trim($lines[$j]));
493+
$part = json_decode(trim($lines[$j]));
494+
$currentMsgid[] = is_string($part) ? $part : '';
493495
$j++;
494496
}
495497
$i = $j - 1;
@@ -603,16 +605,20 @@ private function compileTranslations(string $domain): void
603605
$msgstr = [];
604606
while (($line = fgets($read)) !== false) {
605607
if (substr($line, 0, 5) == 'msgid') {
606-
$msgid = [json_decode(substr(rtrim($line, "\n"), 6))];
608+
$decoded = json_decode(substr(rtrim($line, "\n"), 6));
609+
$msgid = [is_string($decoded) ? $decoded : ''];
607610
$scanid = true;
608611
} elseif (substr($line, 0, 6) == 'msgstr') {
609-
$msgstr = [json_decode(substr(rtrim($line, "\n"), 7))];
612+
$decoded = json_decode(substr(rtrim($line, "\n"), 7));
613+
$msgstr = [is_string($decoded) ? $decoded : ''];
610614
$scanid = false;
611615
} elseif (substr($line, 0, 1) == '"') {
612616
if ($scanid) {
613-
$msgid[] = json_decode(rtrim($line, "\n"));
617+
$part = json_decode(rtrim($line, "\n"));
618+
$msgid[] = is_string($part) ? $part : '';
614619
} else {
615-
$msgstr[] = json_decode(rtrim($line, "\n"));
620+
$part = json_decode(rtrim($line, "\n"));
621+
$msgstr[] = is_string($part) ? $part : '';
616622
}
617623
} else {
618624
$strings[implode('', $msgid)] = implode('', $msgstr);

0 commit comments

Comments
 (0)