Skip to content

Commit a8ba822

Browse files
committed
coding style: fixes in code
1 parent 6264bea commit a8ba822

28 files changed

+102
-101
lines changed

src/Bridges/DatabaseDI/DatabaseExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private function setupDatabase($config, $name): void
117117

118118
if ($config['debugger']) {
119119
$connection->addSetup('@Tracy\BlueScreen::addPanel', [
120-
'Nette\Bridges\DatabaseTracy\ConnectionPanel::renderException'
120+
'Nette\Bridges\DatabaseTracy\ConnectionPanel::renderException',
121121
]);
122122
if ($this->debugMode) {
123123
$connection->addSetup('Nette\Database\Helpers::createDebugPanel', [$connection, !empty($config['explain']), $name]);

src/Bridges/DatabaseTracy/ConnectionPanel.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ class ConnectionPanel implements Tracy\IBarPanel
2424
/** @var int */
2525
public $maxQueries = 100;
2626

27-
/** @var int logged time */
28-
private $totalTime = 0;
29-
30-
/** @var int */
31-
private $count = 0;
32-
33-
/** @var array */
34-
private $queries = [];
35-
3627
/** @var string */
3728
public $name;
3829

@@ -42,6 +33,15 @@ class ConnectionPanel implements Tracy\IBarPanel
4233
/** @var bool */
4334
public $disabled = false;
4435

36+
/** @var int logged time */
37+
private $totalTime = 0;
38+
39+
/** @var int */
40+
private $count = 0;
41+
42+
/** @var array */
43+
private $queries = [];
44+
4545

4646
public function __construct(Nette\Database\Connection $connection)
4747
{

src/Bridges/DatabaseTracy/templates/ConnectionPanel.panel.phtml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,45 @@ use Tracy;
1212
#tracy-debug .nette-DbConnectionPanel-explain td { white-space: pre }
1313
</style>
1414

15-
<h1 title="<?= htmlSpecialChars($connection->getDsn(), ENT_QUOTES, 'UTF-8') ?>">Queries: <?php
16-
echo $count, ($totalTime ? sprintf(', time: %0.3f ms', $totalTime * 1000) : ''), ', ', htmlSpecialChars($name, ENT_NOQUOTES, 'UTF-8') ?></h1>
15+
<h1 title="<?= htmlspecialchars($connection->getDsn(), ENT_QUOTES, 'UTF-8') ?>">Queries: <?php
16+
echo $count, ($totalTime ? sprintf(', time: %0.3f ms', $totalTime * 1000) : ''), ', ', htmlspecialchars($name, ENT_NOQUOTES, 'UTF-8') ?></h1>
1717

1818
<div class="tracy-inner">
1919
<table>
2020
<tr><th>Time&nbsp;ms</th><th>SQL Query</th><th>Rows</th></tr>
2121
<?php
2222
foreach ($queries as $query):
23-
list($connection, $sql, $params, $source, $time, $rows, $error, $explain) = $query;
23+
[$connection, $sql, $params, $source, $time, $rows, $error, $explain] = $query;
2424
?>
2525
<tr>
2626
<td>
2727
<?php if ($error): ?>
28-
<span title="<?= htmlSpecialChars($error, ENT_IGNORE | ENT_QUOTES, 'UTF-8') ?>">ERROR</span>
28+
<span title="<?= htmlspecialchars($error, ENT_IGNORE | ENT_QUOTES, 'UTF-8') ?>">ERROR</span>
2929
<?php elseif ($time !== null): echo sprintf('%0.3f', $time * 1000); endif ?>
3030
<?php if ($explain): ?>
3131
<br /><a class="tracy-toggle tracy-collapsed" data-tracy-ref="^tr .nette-DbConnectionPanel-explain">explain</a>
3232
<?php endif ?>
33-
</td>
34-
<td class="nette-DbConnectionPanel-sql"><?= Helpers::dumpSql($sql, $params, $connection) ?>
33+
</td>
34+
<td class="nette-DbConnectionPanel-sql"><?= Helpers::dumpSql($sql, $params, $connection) ?>
3535
<?php if ($explain): ?>
3636
<table class="tracy-collapsed nette-DbConnectionPanel-explain">
3737
<tr>
3838
<?php foreach ($explain[0] as $col => $foo): ?>
39-
<th><?= htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') ?></th>
39+
<th><?= htmlspecialchars($col, ENT_NOQUOTES, 'UTF-8') ?></th>
4040
<?php endforeach ?>
4141
</tr>
4242
<?php foreach ($explain as $row): ?>
4343
<tr>
4444
<?php foreach ($row as $col): ?>
45-
<td><?= htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') ?></td>
45+
<td><?= htmlspecialchars($col, ENT_NOQUOTES, 'UTF-8') ?></td>
4646
<?php endforeach ?>
4747
</tr>
4848
<?php endforeach ?>
4949
</table>
5050
<?php endif ?>
51-
<?php if ($source) echo substr_replace(Tracy\Helpers::editorLink($source[0], $source[1]), ' class="nette-DbConnectionPanel-source"', 2, 0); ?>
51+
<?php if ($source) {
52+
echo substr_replace(Tracy\Helpers::editorLink($source[0], $source[1]), ' class="nette-DbConnectionPanel-source"', 2, 0);
53+
} ?>
5254
</td>
5355
<td><?= $rows ?></td>
5456
</tr>

src/Bridges/DatabaseTracy/templates/ConnectionPanel.tab.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Nette\Bridges\DatabaseTracy;
44

55
?>
6-
<span title="Nette\Database <?= htmlSpecialChars($name, ENT_QUOTES, 'UTF-8') ?>">
6+
<span title="Nette\Database <?= htmlspecialchars($name, ENT_QUOTES, 'UTF-8') ?>">
77
<svg viewBox="0 0 2048 2048"><path fill="<?= $count ? '#b079d6' : '#aaa' ?>" d="M1024 896q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0 768q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-384q237 0 443-43t325-127v170q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-170q119 84 325 127t443 43zm0-1152q208 0 385 34.5t280 93.5 103 128v128q0 69-103 128t-280 93.5-385 34.5-385-34.5-280-93.5-103-128v-128q0-69 103-128t280-93.5 385-34.5z"/>
88
</svg><span class="tracy-label"><?= ($totalTime ? sprintf('%0.1f ms / ', $totalTime * 1000) : '') . $count ?></span>
99
</span>

src/Database/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ public function quote(string $string, int $type = PDO::PARAM_STR): string
138138
}
139139

140140

141-
function beginTransaction(): void
141+
public function beginTransaction(): void
142142
{
143143
$this->query('::beginTransaction');
144144
}
145145

146146

147-
function commit(): void
147+
public function commit(): void
148148
{
149149
$this->query('::commit');
150150
}

src/Database/Helpers.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Helpers
4141
*/
4242
public static function dumpResult(ResultSet $result): void
4343
{
44-
echo "\n<table class=\"dump\">\n<caption>" . htmlSpecialChars($result->getQueryString(), ENT_IGNORE, 'UTF-8') . "</caption>\n";
44+
echo "\n<table class=\"dump\">\n<caption>" . htmlspecialchars($result->getQueryString(), ENT_IGNORE, 'UTF-8') . "</caption>\n";
4545
if (!$result->getColumnCount()) {
4646
echo "\t<tr>\n\t\t<th>Affected rows:</th>\n\t\t<td>", $result->getRowCount(), "</td>\n\t</tr>\n</table>\n";
4747
return;
@@ -51,13 +51,13 @@ public static function dumpResult(ResultSet $result): void
5151
if ($i === 0) {
5252
echo "<thead>\n\t<tr>\n\t\t<th>#row</th>\n";
5353
foreach ($row as $col => $foo) {
54-
echo "\t\t<th>" . htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') . "</th>\n";
54+
echo "\t\t<th>" . htmlspecialchars($col, ENT_NOQUOTES, 'UTF-8') . "</th>\n";
5555
}
5656
echo "\t</tr>\n</thead>\n<tbody>\n";
5757
}
5858
echo "\t<tr>\n\t\t<th>", $i, "</th>\n";
5959
foreach ($row as $col) {
60-
echo "\t\t<td>", htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8'), "</td>\n";
60+
echo "\t\t<td>", htmlspecialchars($col, ENT_NOQUOTES, 'UTF-8'), "</td>\n";
6161
}
6262
echo "\t</tr>\n";
6363
$i++;
@@ -90,7 +90,7 @@ public static function dumpSql(string $sql, array $params = null, Connection $co
9090
$sql = preg_replace('#([ \t]*\r?\n){2,}#', "\n", $sql);
9191

9292
// syntax highlight
93-
$sql = htmlSpecialChars($sql, ENT_IGNORE, 'UTF-8');
93+
$sql = htmlspecialchars($sql, ENT_IGNORE, 'UTF-8');
9494
$sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])($keywords1)(?=[\\s,)])|(?<=[\\s,(=])($keywords2)(?=[\\s,)=])#is", function ($matches) {
9595
if (!empty($matches[1])) { // comment
9696
return '<em style="color:gray">' . $matches[1] . '</em>';
@@ -128,7 +128,7 @@ public static function dumpSql(string $sql, array $params = null, Connection $co
128128
$info = stream_get_meta_data($param);
129129
}
130130
return '<i' . (isset($info['uri']) ? ' title="' . htmlspecialchars($info['uri'], ENT_NOQUOTES, 'UTF-8') . '"' : null)
131-
. '>&lt;' . htmlSpecialChars($type, ENT_NOQUOTES, 'UTF-8') . ' resource&gt;</i> ';
131+
. '>&lt;' . htmlspecialchars($type, ENT_NOQUOTES, 'UTF-8') . ' resource&gt;</i> ';
132132

133133
} else {
134134
return htmlspecialchars((string) $param, ENT_NOQUOTES, 'UTF-8');

src/Database/ResultSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(Connection $connection, $queryString, array $params)
6060
$connection->getPdo()->{substr($queryString, 2)}();
6161
} elseif ($queryString !== null) {
6262
static $types = ['boolean' => PDO::PARAM_BOOL, 'integer' => PDO::PARAM_INT,
63-
'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL];
63+
'resource' => PDO::PARAM_LOB, 'NULL' => PDO::PARAM_NULL, ];
6464
$this->pdoStatement = $connection->getPdo()->prepare($queryString);
6565
foreach ($params as $key => $value) {
6666
$type = gettype($value);

src/Database/Table/ActiveRow.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __toString()
6161
if (func_num_args()) {
6262
throw $e;
6363
}
64-
trigger_error("Exception in " . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
64+
trigger_error('Exception in ' . __METHOD__ . "(): {$e->getMessage()} in {$e->getFile()}:{$e->getLine()}", E_USER_ERROR);
6565
}
6666
}
6767

src/Database/Table/Selection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ protected function getGeneralCacheKey(): string
660660
$trace = [];
661661
foreach (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $item) {
662662
$trace[] = isset($item['file'], $item['line']) ? $item['file'] . $item['line'] : null;
663-
};
663+
}
664664

665665
$key[] = $trace;
666666
return $this->generalCacheKey = md5(serialize($key));

0 commit comments

Comments
 (0)