improve code style
This commit is contained in:
parent
1aac154bcb
commit
fae28866eb
13
.php-cs-fixer.php
Normal file
13
.php-cs-fixer.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()
|
||||||
|
->in(__DIR__)
|
||||||
|
;
|
||||||
|
|
||||||
|
$config = new PhpCsFixer\Config();
|
||||||
|
return $config->setRules([
|
||||||
|
'@PHP80Migration' => true,
|
||||||
|
'@PSR12' => true
|
||||||
|
])
|
||||||
|
->setFinder($finder)
|
||||||
|
;
|
@ -9,6 +9,7 @@
|
|||||||
"firephp/firephp-core": "^0.5.3"
|
"firephp/firephp-core": "^0.5.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "~3.13.0",
|
||||||
"phpstan/phpstan": "^1.10"
|
"phpstan/phpstan": "^1.10"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
@ -32,6 +33,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/oxid-sql-logger/.php-cs-fixer.php",
|
||||||
|
|
||||||
"phpstan": "./vendor/bin/phpstan --configuration=vendor/d3/oxid-sql-logger/phpstan.neon analyse"
|
"phpstan": "./vendor/bin/phpstan --configuration=vendor/d3/oxid-sql-logger/phpstan.neon analyse"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ use OxidEsales\Eshop\Core\DatabaseProvider;
|
|||||||
|
|
||||||
require __DIR__ . '/../../../../source/bootstrap.php';
|
require __DIR__ . '/../../../../source/bootstrap.php';
|
||||||
|
|
||||||
D3StartSQLLog( 'Query for 100 items cheaper than 49,99');
|
D3StartSQLLog('Query for 100 items cheaper than 49,99');
|
||||||
|
|
||||||
$db = DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC);
|
$db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
|
||||||
$list = $db->getAll('SELECT * '.PHP_EOL.'FROM oxarticles WHERE oxprice < ? LIMIT 100', [49.99]);
|
$list = $db->getAll('SELECT * '.PHP_EOL.'FROM oxarticles WHERE oxprice < ? LIMIT 100', [49.99]);
|
||||||
|
|
||||||
D3StopSQLLog();
|
D3StopSQLLog();
|
||||||
@ -17,7 +17,7 @@ D3StopSQLLog();
|
|||||||
|
|
||||||
D3StartSQLLog();
|
D3StartSQLLog();
|
||||||
|
|
||||||
$db = DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC);
|
$db = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC);
|
||||||
$list = $db->getAll('SELECT * FROM oxarticles WHERE oxprice < ? LIMIT 100', [49.99]);
|
$list = $db->getAll('SELECT * FROM oxarticles WHERE oxprice < ? LIMIT 100', [49.99]);
|
||||||
|
|
||||||
D3StopSQLLog();
|
D3StopSQLLog();
|
||||||
|
@ -73,8 +73,8 @@ class d3FirePHP extends FirePHP
|
|||||||
*/
|
*/
|
||||||
public function trace($label): bool
|
public function trace($label): bool
|
||||||
{
|
{
|
||||||
return $this->fb($label, $label, FirePHP::TRACE, array(
|
return $this->fb($label, $label, FirePHP::TRACE, [
|
||||||
'trace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)
|
'trace' => debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS),
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,7 +22,7 @@ use OxidEsales\Eshop\Core\Registry;
|
|||||||
|
|
||||||
class d3FirePHPHandler extends AbstractProcessingHandler
|
class d3FirePHPHandler extends AbstractProcessingHandler
|
||||||
{
|
{
|
||||||
const ADD_TRACE = 'addTrace';
|
public const ADD_TRACE = 'addTrace';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $record
|
* @param array $record
|
||||||
@ -37,13 +37,13 @@ class d3FirePHPHandler extends AbstractProcessingHandler
|
|||||||
$fp = d3FirePHP::getInstance(true);
|
$fp = d3FirePHP::getInstance(true);
|
||||||
|
|
||||||
if (in_array(self::ADD_TRACE, $options)) {
|
if (in_array(self::ADD_TRACE, $options)) {
|
||||||
$fp->group( $record['message'], [ 'Collapsed' => true ] );
|
$fp->group($record['message'], [ 'Collapsed' => true ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fp->log( $record['formatted'], $record['message']);
|
$fp->log($record['formatted'], $record['message']);
|
||||||
|
|
||||||
if (in_array(self::ADD_TRACE, $options)) {
|
if (in_array(self::ADD_TRACE, $options)) {
|
||||||
$fp->trace( 'trace');
|
$fp->trace('trace');
|
||||||
$fp->groupEnd();
|
$fp->groupEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ class LoggerFactory
|
|||||||
$handlers = (isset($configuredHandlers) && is_iterable($configuredHandlers)) ?
|
$handlers = (isset($configuredHandlers) && is_iterable($configuredHandlers)) ?
|
||||||
$this->getInstancesFromHandlerList($configuredHandlers) :
|
$this->getInstancesFromHandlerList($configuredHandlers) :
|
||||||
[
|
[
|
||||||
$this->getStreamHandler()
|
$this->getStreamHandler(),
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$configuredHandlers = Registry::getConfig()->getConfigParam('SqlLoggerGUIHandlers');
|
$configuredHandlers = Registry::getConfig()->getConfigParam('SqlLoggerGUIHandlers');
|
||||||
@ -46,7 +46,7 @@ class LoggerFactory
|
|||||||
$this->getInstancesFromHandlerList($configuredHandlers) :
|
$this->getInstancesFromHandlerList($configuredHandlers) :
|
||||||
[
|
[
|
||||||
$this->getBrowserConsoleHandler(),
|
$this->getBrowserConsoleHandler(),
|
||||||
$this->getFirePHPHandler()
|
$this->getFirePHPHandler(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class LoggerFactory
|
|||||||
private function getInstancesFromHandlerList(iterable $classNames): array
|
private function getInstancesFromHandlerList(iterable $classNames): array
|
||||||
{
|
{
|
||||||
return array_map(
|
return array_map(
|
||||||
function($className){
|
function ($className) {
|
||||||
return new $className();
|
return new $className();
|
||||||
},
|
},
|
||||||
(array) $classNames
|
(array) $classNames
|
||||||
@ -122,7 +122,7 @@ class LoggerFactory
|
|||||||
[
|
[
|
||||||
'D3\\OxidSqlLogger',
|
'D3\\OxidSqlLogger',
|
||||||
'Doctrine\\DBAL\\Connection',
|
'Doctrine\\DBAL\\Connection',
|
||||||
'OxidEsales\\EshopCommunity\\Core\\Database\\Adapter\\Doctrine\\Database'
|
'OxidEsales\\EshopCommunity\\Core\\Database\\Adapter\\Doctrine\\Database',
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
new Monolog\Processor\PsrLogMessageProcessor(),
|
new Monolog\Processor\PsrLogMessageProcessor(),
|
||||||
|
@ -56,7 +56,7 @@ class OxidSQLLogger implements SQLLogger
|
|||||||
$this->stopQuery();
|
$this->stopQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getPreparedStatementQuery( $sql, $params ?? [], $types ?? []);
|
$this->getPreparedStatementQuery($sql, $params ?? [], $types ?? []);
|
||||||
|
|
||||||
$this->SQLQuery = (new SQLQuery())->setSql($sql)
|
$this->SQLQuery = (new SQLQuery())->setSql($sql)
|
||||||
->setParams($params)
|
->setParams($params)
|
||||||
|
@ -20,7 +20,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
|||||||
function D3StartSQLLog(string $message = null): void
|
function D3StartSQLLog(string $message = null): void
|
||||||
{
|
{
|
||||||
/** @var OxidEsalesDatabase $database */
|
/** @var OxidEsalesDatabase $database */
|
||||||
$database = oxNew( OxidEsalesDatabase::class);
|
$database = oxNew(OxidEsalesDatabase::class);
|
||||||
$database->d3EnableLogger($message);
|
$database->d3EnableLogger($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ function D3StartSQLLog(string $message = null): void
|
|||||||
function D3StopSQLLog(): void
|
function D3StopSQLLog(): void
|
||||||
{
|
{
|
||||||
/** @var OxidEsalesDatabase $database */
|
/** @var OxidEsalesDatabase $database */
|
||||||
$database = oxNew( OxidEsalesDatabase::class);
|
$database = oxNew(OxidEsalesDatabase::class);
|
||||||
$database->d3DisableLogger();
|
$database->d3DisableLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,9 +44,9 @@ function D3StopSQLLog(): void
|
|||||||
function D3AddSQLLogItem(string $message): void
|
function D3AddSQLLogItem(string $message): void
|
||||||
{
|
{
|
||||||
/** @var OxidEsalesDatabase $database */
|
/** @var OxidEsalesDatabase $database */
|
||||||
$database = oxNew( OxidEsalesDatabase::class);
|
$database = oxNew(OxidEsalesDatabase::class);
|
||||||
if ($logger = $database->d3GetLogger()) {
|
if ($logger = $database->d3GetLogger()) {
|
||||||
$logger->startQuery( $message );
|
$logger->startQuery($message);
|
||||||
$logger->stopQuery();
|
$logger->stopQuery();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user