improve code style
This commit is contained in:
parent
153ce3f5ec
commit
b58391c02c
@ -1,13 +1,35 @@
|
||||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in(__DIR__)
|
||||
;
|
||||
declare(strict_types=1);
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()->in(__DIR__);
|
||||
|
||||
$header = <<<EOF
|
||||
Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
|
||||
For the full copyright and license information, please view
|
||||
the LICENSE file that was distributed with this source code.
|
||||
|
||||
https://www.d3data.de
|
||||
|
||||
@copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
@author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
@link https://www.oxidmodule.com
|
||||
EOF;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRules([
|
||||
'@PHP73Migration' => true,
|
||||
'@PSR12' => true
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
return $config->setRules(
|
||||
[
|
||||
'@PHP80Migration' => true,
|
||||
'@PSR12' => true,
|
||||
'header_comment' => [
|
||||
'comment_type' => 'PHPDoc',
|
||||
'header' => $header,
|
||||
'location' => 'after_open',
|
||||
'separate' => 'both',
|
||||
],
|
||||
'php_unit_test_class_requires_covers' => true,
|
||||
'doctrine_annotation_indentation' => true,
|
||||
]
|
||||
)
|
||||
->setFinder($finder);
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
* @copyright (c) 2016 Dmitry Kosenkov
|
||||
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
||||
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
||||
* @link https://www.oxidmodule.com
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
@ -19,8 +21,7 @@ use DebugBar\DataCollector\TimeDataCollector;
|
||||
|
||||
class TimeDataCollectorHandler
|
||||
{
|
||||
/** @var TimeDataCollector */
|
||||
private static $instance = null;
|
||||
private static TimeDataCollector|null $instance = null;
|
||||
|
||||
/**
|
||||
* @return TimeDataCollector
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
@ -52,20 +54,14 @@ class DebugBarErrorHandler
|
||||
[ $file, $line ] = $smartyTemplate;
|
||||
}
|
||||
|
||||
switch ($severity) {
|
||||
case E_CORE_ERROR:
|
||||
throw new CoreErrorException($message, 0, $severity, $file, $line);
|
||||
case E_COMPILE_ERROR:
|
||||
throw new CompileErrorException($message, 0, $severity, $file, $line);
|
||||
case E_USER_ERROR:
|
||||
throw new UserErrorException($message, 0, $severity, $file, $line);
|
||||
case E_PARSE:
|
||||
throw new ParseException($message, 0, $severity, $file, $line);
|
||||
case E_ERROR:
|
||||
throw new ErrorException($message, 0, $severity, $file, $line);
|
||||
default:
|
||||
$this->handleUnregisteredErrorTypes($message, $severity, $file, $line);
|
||||
}
|
||||
throw match ($severity) {
|
||||
E_CORE_ERROR => new CoreErrorException($message, 0, $severity, $file, $line),
|
||||
E_COMPILE_ERROR => new CompileErrorException($message, 0, $severity, $file, $line),
|
||||
E_USER_ERROR => new UserErrorException($message, 0, $severity, $file, $line),
|
||||
E_PARSE => new ParseException($message, 0, $severity, $file, $line),
|
||||
E_ERROR => new ErrorException($message, 0, $severity, $file, $line),
|
||||
default => $this->handleUnregisteredErrorTypes($message, $severity, $file, $line),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
@ -20,11 +22,10 @@ use D3\DebugBar\Application\Models\AvailabilityCheck;
|
||||
use D3\DebugBar\Application\Models\Exceptions\UnavailableException;
|
||||
use DebugBar\DataCollector\ExceptionsCollector;
|
||||
use DebugBar\DebugBarException;
|
||||
use OxidEsales\Eshop\Core\ConfigFile;
|
||||
use OxidEsales\Eshop\Core\Exception\ExceptionHandler;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Logger\LoggerServiceFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Transition\Utility\Context;
|
||||
use ReflectionException;
|
||||
use Throwable;
|
||||
|
||||
class DebugBarExceptionHandler
|
||||
@ -33,27 +34,25 @@ class DebugBarExceptionHandler
|
||||
* Handler for uncaught exceptions.
|
||||
*
|
||||
* @param Throwable $exception exception object
|
||||
*
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function handleUncaughtException(Throwable $exception): void
|
||||
{
|
||||
try {
|
||||
/** @var int $debugMode */
|
||||
$debugMode = Registry::get(ConfigFile::class)->getVar('iDebug');
|
||||
$defaultExceptionHandler = new ExceptionHandler($debugMode);
|
||||
$defaultExceptionHandler->writeExceptionToLog($exception);
|
||||
} catch (Throwable $loggerException) {
|
||||
Registry::getLogger()->error(
|
||||
$exception->getMessage(),
|
||||
[$exception]
|
||||
);
|
||||
} catch (Throwable) {
|
||||
/**
|
||||
* It's not possible to get the logger from the DI container.
|
||||
* Try again to log original exception (without DI container) in order to show the root cause of a problem.
|
||||
*/
|
||||
try {
|
||||
$loggerServiceFactory = new LoggerServiceFactory(new Context());
|
||||
$logger = $loggerServiceFactory->getLogger();
|
||||
$logger->error($exception->getTraceAsString());
|
||||
} catch (Throwable $throwableWithoutPossibilityToWriteToLogFile) {
|
||||
// It's not possible to log because e.g. the log file is not writable.
|
||||
}
|
||||
$logger->error($exception);
|
||||
}
|
||||
|
||||
if (AvailabilityCheck::isAvailable() && AvailabilityCheck::ifDebugBarNotSet()) {
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
@ -18,9 +20,11 @@ namespace D3\DebugBar\Modules\Core;
|
||||
use D3\DebugBar\Application\Component\DebugBarComponent;
|
||||
use D3\DebugBar\Application\Models\AvailabilityCheck;
|
||||
use D3\DebugBar\Application\Models\DebugBarHandler;
|
||||
use D3\DebugBar\Application\Models\Exceptions\UnavailableException;
|
||||
use D3\DebugBar\Core\DebugBarExceptionHandler;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use ReflectionException;
|
||||
use Throwable;
|
||||
|
||||
class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||
@ -39,8 +43,11 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||
/**
|
||||
* @param string|null $controllerKey
|
||||
* @param string|null $function
|
||||
* @param array $parameters
|
||||
* @param array $viewsChain
|
||||
* @param array|null $parameters
|
||||
* @param array|null $viewsChain
|
||||
*
|
||||
* @throws UnavailableException
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function start($controllerKey = null, $function = null, $parameters = null, $viewsChain = null)
|
||||
{
|
||||
@ -63,7 +70,9 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||
|
||||
/**
|
||||
* @param Throwable $exception
|
||||
*
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
protected function debugBarHandleException(Throwable $exception): void
|
||||
{
|
||||
@ -73,6 +82,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||
|
||||
/**
|
||||
* @param StandardException $exception
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
protected function _handleSystemException($exception)
|
||||
{
|
||||
@ -81,6 +92,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||
|
||||
/**
|
||||
* @param StandardException $exception
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
protected function _handleCookieException($exception)
|
||||
{
|
||||
@ -89,6 +102,8 @@ class ShopControl_DebugBar extends ShopControl_DebugBar_parent
|
||||
|
||||
/**
|
||||
* @param StandardException $exception
|
||||
*
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
protected function _handleBaseException($exception)
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
@ -81,7 +83,7 @@ function stopProfile(string $sProfileName): void
|
||||
* @throws DebugBarException
|
||||
* @return void
|
||||
*/
|
||||
function debugVar($mVar, bool $blToFile = false): void
|
||||
function debugVar(mixed $mVar, bool $blToFile = false): void
|
||||
{
|
||||
if ($blToFile) {
|
||||
$out = var_export($mVar, true);
|
||||
@ -106,10 +108,9 @@ function debugVar($mVar, bool $blToFile = false): void
|
||||
/** @var MessagesCollector $messages */
|
||||
$messages = $debugBarComponent->getDebugBar()->getCollector('messages');
|
||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
//$location = $trace[1]['class'] . '::' . $trace[1]['function']. '(' . $trace[0]['line'] . ')';
|
||||
$location = $trace[1]['class'] . '::' . $trace[1]['function'];
|
||||
$messages->addMessage($mVar, $location);
|
||||
} catch (UnavailableException $e) {
|
||||
} catch (UnavailableException) {
|
||||
dumpVar($mVar, $blToFile);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
1
ToDo.md
1
ToDo.md
@ -2,4 +2,3 @@
|
||||
|
||||
- clear tpl cache button
|
||||
- phpinfo() overview
|
||||
- automatic switch between Smarty and Twig
|
||||
|
@ -40,5 +40,8 @@
|
||||
"psr-4": {
|
||||
"D3\\DebugBar\\": ""
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/oxid-debugbar/.php-cs-fixer.php"
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*
|
||||
* https://www.d3data.de
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user