Skip to content

Commit

Permalink
update conding style (remove intro doc, normalized all files)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrach committed May 28, 2020
1 parent 04c497e commit 984cea1
Show file tree
Hide file tree
Showing 54 changed files with 348 additions and 380 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 1,9 @@
/composer.lock
/vendor
/.idea

!/.idea
/.idea/*
!/.idea/codeStyles
!/.idea/codeStyles/codeStyleConfig.xml
!/.idea/codeStyles/Project.xml
!/.idea/sqldialects.xml
60 changes: 60 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions src/Bridges/NetteCaching/CachedPlatform.php
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\NetteCaching;


use Nette\Caching\Cache;
use Nextras\Dbal\Platforms\IPlatform;

Expand Down Expand Up @@ -39,7 34,7 @@ public function getName(): string
/** @inheritDoc */
public function getTables(?string $schema = null): array
{
return $this->cache->load(self::CACHE_VERSION . '.tables.' . $schema , function () use ($schema) {
return $this->cache->load(self::CACHE_VERSION . '.tables.' . $schema, function () use ($schema) {
return $this->platform->getTables($schema);
});
}
Expand Down
12 changes: 5 additions & 7 deletions src/Bridges/NetteDI/DbalExtension.php
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\NetteDI;


use Nette\DI\CompilerExtension;
use Nextras\Dbal\Bridges\NetteTracy\BluescreenQueryPanel;
use Nextras\Dbal\Bridges\NetteTracy\ConnectionPanel;
Expand Down Expand Up @@ -47,7 42,10 @@ protected function setupConnection(array $config): void

if ($debugger) {
$definition->addSetup('@Tracy\BlueScreen::addPanel', [BluescreenQueryPanel::class . '::renderBluescreenPanel']);
$definition->addSetup(ConnectionPanel::class . '::install', ['@self', $config['panelQueryExplain'] ?? true]);
$definition->addSetup(
ConnectionPanel::class . '::install',
['@self', $config['panelQueryExplain'] ?? true]
);
}
}
}
7 changes: 1 addition & 6 deletions src/Bridges/NetteTracy/BluescreenQueryPanel.php
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\NetteTracy;


use Nextras\Dbal\QueryException;
use Nextras\Dbal\Utils\SqlHighlighter;

Expand Down
135 changes: 78 additions & 57 deletions src/Bridges/NetteTracy/ConnectionPanel.panel.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 4,56 @@ namespace Nextras\Dbal\Bridges\NetteTracy;

?>
<style class="tracy-debug">
#tracy-debug .nextras-dbal-panel-sql { background: white !important; }
#tracy-debug .nextras-dbal-panel-sql > span, #tracy-debug .nextras-dbal-panel-sql > span > a { color: #777 !important; }
#tracy-debug .nextras-dbal-panel-sql > span > a:hover { color: #fff !important; }
#tracy-debug .nextras-dbal-panel-sql > span { margin-right: 1em !important; }
#tracy-debug .nextras-dbal-panel-sql .whitespace-explain { white-space: pre; !important; }
#tracy-debug .nextras-dbal-panel-time { text-align: right !important; white-space: nowrap !important; max-width: 70px !important; }
#tracy-debug .nextras-dbal-panel-sql {
background: white !important;
}

#tracy-debug .nextras-dbal-panel-sql > span, #tracy-debug .nextras-dbal-panel-sql > span > a {
color: #777 !important;
}

#tracy-debug .nextras-dbal-panel-sql > span > a:hover {
color: #fff !important;
}

#tracy-debug .nextras-dbal-panel-sql > span {
margin-right: 1em !important;
}

#tracy-debug .nextras-dbal-panel-sql .whitespace-explain {
white-space: pre !important;
}

#tracy-debug .nextras-dbal-panel-time {
text-align: right !important;
white-space: nowrap !important;
max-width: 70px !important;
}
</style>

<script>
function nextrasDbalPanelCopySql(e, containerId) {
e.preventDefault();
const str = document.getElementById(containerId).textContent;
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
const selected =
document.getSelection().rangeCount > 0
? document.getSelection().getRangeAt(0)
: false;
el.select();
document.execCommand('copy');
document.body.removeChild(el);
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
}
return false;
}
function nextrasDbalPanelCopySql(e, containerId) {
e.preventDefault();
const str = document.getElementById(containerId).textContent;
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
const selected =
document.getSelection().rangeCount > 0
? document.getSelection().getRangeAt(0)
: false;
el.select();
document.execCommand('copy');
document.body.removeChild(el);
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
}
return false;
}
</script>

<h1>Queries: <?php echo $count ?></h1>
Expand All @@ -46,36 65,38 @@ namespace Nextras\Dbal\Bridges\NetteTracy;
</tr>
<?php
foreach ($queries as $query):
list(, $sql, $elapsedTime, $rowsCount, $explain) = $query;
[, $sql, $elapsedTime, $rowsCount, $explain] = $query;
$uniqRowId = uniqid('nextras-dbal-sql-');
?>
<tr>
<td class="nextras-dbal-panel-time"><?php echo $elapsedTime ? sprintf('%0.2f', $elapsedTime * 1000) : '' ?></td>
<td class="nextras-dbal-panel-sql">
<div id="<?php echo $uniqRowId; ?>"><?php echo $sql ?></div>
<?php if ($rowsCount !== null): ?>
<span class="nextras-dbal-rowscount"><?php echo $rowsCount === 1 ? $rowsCount . ' row' : $rowsCount . ' rows' ?></span>
<?php endif; ?>
<span><a href="" onclick="nextrasDbalPanelCopySql(event, '<?php echo $uniqRowId; ?>')">copy</a></span>
<?php if ($explain !== null): ?>
<span><a class="tracy-toggle tracy-collapsed" data-tracy-ref="^tr .nextras-dbal-explain">explain</a></span>
<table class="tracy-collapsed nextras-dbal-explain">
<tr>
<?php foreach ($explain[0] as $col => $foo): ?>
<th><?php echo htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') ?></th>
<?php endforeach ?>
</tr>
<?php foreach ($explain as $row): ?>
<tr>
<?php foreach ($row as $col): ?>
<td class="<?php echo $whitespaceExplain ? 'whitespace-explain' : '' ?>"><?php echo htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') ?></td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</table>
<?php endif; ?>
</td>
</tr>
?>
<tr>
<td class="nextras-dbal-panel-time"><?php echo $elapsedTime ? sprintf('%0.2f', $elapsedTime * 1000) : '' ?></td>
<td class="nextras-dbal-panel-sql">
<div id="<?php echo $uniqRowId; ?>"><?php echo $sql ?></div>
<?php if ($rowsCount !== null): ?>
<span class="nextras-dbal-rowscount"><?php echo $rowsCount === 1 ? $rowsCount . ' row' : $rowsCount . ' rows' ?></span>
<?php endif; ?>
<span><a href=""
onclick="nextrasDbalPanelCopySql(event, '<?php echo $uniqRowId; ?>')">copy</a></span>
<?php if ($explain !== null): ?>
<span><a class="tracy-toggle tracy-collapsed"
data-tracy-ref="^tr .nextras-dbal-explain">explain</a></span>
<table class="tracy-collapsed nextras-dbal-explain">
<tr>
<?php foreach ($explain[0] as $col => $foo): ?>
<th><?php echo htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') ?></th>
<?php endforeach ?>
</tr>
<?php foreach ($explain as $row): ?>
<tr>
<?php foreach ($row as $col): ?>
<td class="<?php echo $whitespaceExplain ? 'whitespace-explain' : '' ?>"><?php echo htmlSpecialChars($col, ENT_NOQUOTES, 'UTF-8') ?></td>
<?php endforeach ?>
</tr>
<?php endforeach ?>
</table>
<?php endif; ?>
</td>
</tr>
<?php endforeach ?>
</table>
<?php if (count($queries) < $count): ?><p>...and more</p><?php endif ?>
Expand Down
7 changes: 1 addition & 6 deletions src/Bridges/NetteTracy/ConnectionPanel.php
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\NetteTracy;


use Nextras\Dbal\Drivers\Exception\DriverException;
use Nextras\Dbal\IConnection;
use Nextras\Dbal\ILogger;
Expand Down
3 changes: 2 additions & 1 deletion src/Bridges/NetteTracy/ConnectionPanel.tab.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,8 @@ namespace Nextras\Dbal\Bridges\NetteTracy;

?>
<span title="Nextras\Dbal query panel">
<svg viewBox="0 0 2048 2048"><path fill="<?php echo $count ? '#2D44AD' : '#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"/>
<svg viewBox="0 0 2048 2048"><path fill="<?php echo $count ? '#2D44AD' : '#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"/>
</svg>
<span class="tracy-label">
<?php echo $count ?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\SymfonyBundle\DataCollector;


use Nextras\Dbal\Drivers\Exception\DriverException;
use Nextras\Dbal\IConnection;
use Nextras\Dbal\ILogger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\SymfonyBundle\DependencyInjection;


use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use function array_key_exists;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\SymfonyBundle\DependencyInjection;


use Nextras\Dbal\Bridges\SymfonyBundle\DataCollector\QueryDataCollector;
use Nextras\Dbal\Connection;
use Nextras\Dbal\IConnection;
Expand Down
7 changes: 1 addition & 6 deletions src/Bridges/SymfonyBundle/NextrasDbalBundle.php
Original file line number Diff line number Diff line change
@@ -1,13 1,8 @@
<?php declare(strict_types = 1);

/**
* This file is part of the Nextras\Dbal library.
* @license MIT
* @link https://github.com/nextras/dbal
*/

namespace Nextras\Dbal\Bridges\SymfonyBundle;


use Symfony\Component\HttpKernel\Bundle\Bundle;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 109,11 @@
{% if query.rowsCount != null %}
<span class="nextras-dbal-rowscount text-muted">{{ query.rowsCount }} {% if query.rowsCount == 1 %}row{% else %}rows{% endif %}</span>
{% endif %}
<span><a href="" class="text-muted" onclick="nextrasDbalPanelCopySql(event, this)">copy</a></span>
<span><a href="" class="text-muted"
onclick="nextrasDbalPanelCopySql(event, this)">copy</a></span>
{% if query.explain != null %}
<span><a href="" class="text-muted sf-toggle" data-toggle-selector="#{{ query.uniqId }}" data-toggle-alt-content="hide explain">show explain</a></span>
<span><a href="" class="text-muted sf-toggle" data-toggle-selector="#{{ query.uniqId }}"
data-toggle-alt-content="hide explain">show explain</a></span>
<div id="{{ query.uniqId }}" class="sf-toggle-content sf-toggle-hidden">
<table class="nextras-dbal-explain">
<tr>
Expand Down
Loading

0 comments on commit 984cea1

Please sign in to comment.