Skip to content

Commit 9be5b49

Browse files
committed
strict fixes
1 parent 4db1dfd commit 9be5b49

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/Tracy/Bar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ private function renderPanels(string $suffix = null): array
145145
foreach ($this->panels as $id => $panel) {
146146
$idHtml = preg_replace('#[^a-z0-9]+#i', '-', $id) . $suffix;
147147
try {
148-
$tab = (string) $panel->getTab();
149-
$panelHtml = $tab ? (string) $panel->getPanel() : null;
148+
$tab = $panel->getTab();
149+
$panelHtml = $tab ? $panel->getPanel() : null;
150150
if ($tab && $panel instanceof \Nette\Diagnostics\IBarPanel) {
151151
$e = new \Exception('Support for Nette\Diagnostics\IBarPanel is deprecated');
152152
}

src/Tracy/Dumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ private static function dumpObject(&$var, array $options, int $level): string
231231
$editorAttributes = '';
232232
if ($options[self::LOCATION] & self::LOCATION_CLASS) {
233233
$rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var);
234-
$editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine());
234+
$editor = $rc->getFileName() ? Helpers::editorUri($rc->getFileName(), $rc->getStartLine()) : null;
235235
if ($editor) {
236236
$editorAttributes = Helpers::formatHtml(
237237
' title="Declared in file % on line %" data-tracy-href="%"',
@@ -340,7 +340,7 @@ private static function toJson(&$var, array $options, int $level = 0)
340340
$editorInfo = null;
341341
if ($options[self::LOCATION] & self::LOCATION_CLASS) {
342342
$rc = $var instanceof \Closure ? new \ReflectionFunction($var) : new \ReflectionClass($var);
343-
$editor = Helpers::editorUri($rc->getFileName(), $rc->getStartLine());
343+
$editor = $rc->getFileName() ? Helpers::editorUri($rc->getFileName(), $rc->getStartLine()) : null;
344344
$editorInfo = $editor ? ['file' => $rc->getFileName(), 'line' => $rc->getStartLine(), 'url' => $editor] : null;
345345
}
346346
static $counter = 1;

src/Tracy/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static function editorUri(string $file, int $line = null, string $action
5050
return strtr(Debugger::$editor, [
5151
'%action' => $action,
5252
'%file' => rawurlencode($file),
53-
'%line' => $line ? (int) $line : 1,
53+
'%line' => $line ?: 1,
5454
'%search' => rawurlencode($search),
5555
'%replace' => rawurlencode($replace),
5656
]);

src/Tracy/assets/Bar/errors.panel.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Tracy;
1717
<?php foreach ($data as $item => $count): list($file, $line, $message) = explode('|', $item, 3) ?>
1818
<tr>
1919
<td class="tracy-right"><?= $count ? "$count\xC3\x97" : '' ?></td>
20-
<td><pre><?= Helpers::escapeHtml($message), ' in ', Helpers::editorLink($file, $line) ?></pre></td>
20+
<td><pre><?= Helpers::escapeHtml($message), ' in ', Helpers::editorLink($file, (int) $line) ?></pre></td>
2121
</tr>
2222
<?php endforeach ?>
2323
</table>

src/Tracy/assets/Bar/info.panel.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $info = array_map('strval', array_filter($info + (array) $this->data));
4848
$packages = $devPackages = [];
4949
if (class_exists('Composer\Autoload\ClassLoader', false)) {
5050
$lockFile = dirname((new \ReflectionClass('Composer\Autoload\ClassLoader'))->getFileName()) . '/../../composer.lock';
51-
$composer = @json_decode(file_get_contents($lockFile)); // @ may not exist or be valid
51+
$composer = @json_decode((string) file_get_contents($lockFile)); // @ may not exist or be valid
5252
list($packages, $devPackages) = [(array) @$composer->packages, (array) @$composer->{'packages-dev'}]; // @ keys may not exist
5353
$tmp = [&$packages, &$devPackages];
5454
foreach ($tmp as &$items) {

0 commit comments

Comments
 (0)