improve code style

Cette révision appartient à :
Daniel Seifert 2025-03-25 09:20:39 +01:00
Parent 153ce3f5ec
révision b58391c02c
26 fichiers modifiés avec 178 ajouts et 107 suppressions

Voir le fichier

@ -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);

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*
@ -89,11 +91,11 @@ class OxidConfigCollector extends DataCollector implements Renderable
$search = array_merge($generic, $specific);
foreach ($this->configVars as $group => $values) {
array_walk( $this->configVars[$group], function( $item, $key ) use ( $group, $search ) {
if ( in_array( $key, $search ) ) {
array_walk($this->configVars[$group], function ($item, $key) use ($group, $search) {
if (in_array($key, $search)) {
$this->configVars[$group][ $key ] = self::HIDDEN_TEXT;
}
} );
});
}
}

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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),
};
}
/**
@ -75,7 +71,7 @@ class DebugBarErrorHandler
protected function getSmartyTemplateLocationFromError(string $messsage): ?array
{
if (stristr($messsage, 'Smarty error: [in ')) {
$start = strpos($messsage, '[')+1;
$start = strpos($messsage, '[') + 1;
$end = strpos($messsage, ']');
$parts = explode(' ', substr($messsage, $start, $end - $start));
return [Registry::getConfig()->getTemplateDir(isAdmin()).$parts[1], (int) $parts[3]];

Voir le fichier

@ -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.
}
$loggerServiceFactory = new LoggerServiceFactory(new Context());
$logger = $loggerServiceFactory->getLogger();
$logger->error($exception);
}
if (AvailabilityCheck::isAvailable() && AvailabilityCheck::ifDebugBarNotSet()) {
@ -66,23 +65,23 @@ class DebugBarExceptionHandler
$excCollector->addThrowable($exception);
echo <<<HTML
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
HTML;
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
HTML;
echo $debugBarComponent->getRenderer()->renderHead();
$debugBarComponent->addTimelineMeasures();
echo <<<HTML
</head>
<body>
HTML;
</head>
<body>
HTML;
AvailabilityCheck::markDebugBarAsSet();
echo $debugBarComponent->getRenderer()->render();
echo <<<HTML
</body>
</html>
HTML;
</body>
</html>
HTML;
} catch (DebugBarException|UnavailableException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);

Voir le fichier

@ -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
*

Voir le fichier

@ -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
*

Voir le fichier

@ -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)
{

Voir le fichier

@ -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);
}
}

Voir le fichier

@ -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
*

Voir le fichier

@ -2,4 +2,3 @@
- clear tpl cache button
- phpinfo() overview
- automatic switch between Smarty and Twig

Voir le fichier

@ -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"
}
}

Voir le fichier

@ -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
*