apply code style rules

This commit is contained in:
Daniel Seifert 2022-08-03 09:17:43 +02:00
parent f097a58691
commit 0d4662edf5
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
6 changed files with 72 additions and 69 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.php_cs.cache

View File

@ -22,93 +22,93 @@ use Smarty;
class SmartyCollector extends DataCollector implements Renderable class SmartyCollector extends DataCollector implements Renderable
{ {
/** @var Smarty */ /** @var Smarty */
protected $smarty; protected $smarty;
/** /**
* @var bool * @var bool
*/ */
protected $useHtmlVarDumper = false; protected $useHtmlVarDumper = false;
/** /**
* Sets a flag indicating whether the Symfony HtmlDumper will be used to dump variables for * Sets a flag indicating whether the Symfony HtmlDumper will be used to dump variables for
* rich variable rendering. * rich variable rendering.
* *
* @param bool $value * @param bool $value
* @return $this * @return $this
*/ */
public function useHtmlVarDumper($value = true) public function useHtmlVarDumper($value = true)
{ {
$this->useHtmlVarDumper = $value; $this->useHtmlVarDumper = $value;
return $this; return $this;
} }
/** /**
* Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable * Indicates whether the Symfony HtmlDumper will be used to dump variables for rich variable
* rendering. * rendering.
* *
* @return mixed * @return mixed
*/ */
public function isHtmlVarDumperUsed() public function isHtmlVarDumperUsed()
{ {
return $this->useHtmlVarDumper; return $this->useHtmlVarDumper;
} }
/** /**
* @param Smarty $smarty * @param Smarty $smarty
*/ */
public function __construct(Smarty $smarty) public function __construct(Smarty $smarty)
{ {
$this->smarty = $smarty; $this->smarty = $smarty;
} }
/** /**
* @return array * @return array
*/ */
public function collect(): array public function collect(): array
{ {
$data = []; $data = [];
$vars = $this->smarty->get_template_vars(); $vars = $this->smarty->get_template_vars();
foreach ($vars as $idx => $var) { foreach ($vars as $idx => $var) {
if ($this->isHtmlVarDumperUsed()) { if ($this->isHtmlVarDumperUsed()) {
$data[$idx] = $this->getVarDumper()->renderVar($var); $data[$idx] = $this->getVarDumper()->renderVar($var);
} else { } else {
$data[$idx] = $this->getDataFormatter()->formatVar($var); $data[$idx] = $this->getDataFormatter()->formatVar($var);
} }
} }
return ['vars' => $data, 'count' => count($data)]; return ['vars' => $data, 'count' => count($data)];
} }
/** /**
* @return string * @return string
*/ */
public function getName(): string public function getName(): string
{ {
return 'smarty'; return 'smarty';
} }
/** /**
* @return array * @return array
*/ */
public function getWidgets(): array public function getWidgets(): array
{ {
$widget = $this->isHtmlVarDumperUsed() $widget = $this->isHtmlVarDumperUsed()
? "PhpDebugBar.Widgets.HtmlVariableListWidget" ? "PhpDebugBar.Widgets.HtmlVariableListWidget"
: "PhpDebugBar.Widgets.VariableListWidget"; : "PhpDebugBar.Widgets.VariableListWidget";
return array( return [
"smarty" => array( "smarty" => [
"icon" => "tags", "icon" => "tags",
"widget" => $widget, "widget" => $widget,
"map" => "smarty.vars", "map" => "smarty.vars",
"default" => "{}" "default" => "{}",
), ],
"smarty:badge" => array( "smarty:badge" => [
"map" => "smarty.count", "map" => "smarty.count",
"default" => 0 "default" => 0,
) ],
); ];
} }
} }

View File

@ -32,4 +32,4 @@ class TimeDataCollectorHandler
} }
return self::$instance; return self::$instance;
} }
} }

View File

@ -17,5 +17,7 @@ namespace D3\DebugBar\Modules\Core {
use OxidEsales\Eshop\Core\ShopControl; use OxidEsales\Eshop\Core\ShopControl;
class ShopControl_DebugBar_parent extends ShopControl{} class ShopControl_DebugBar_parent extends ShopControl
} {
}
}

View File

@ -85,8 +85,8 @@ function debugVar($mVar, bool $blToFile = false): void
$out = var_export($mVar, true); $out = var_export($mVar, true);
$f = fopen(Registry::getConfig()->getConfigParam('sCompileDir') . "/vardump.txt", "a"); $f = fopen(Registry::getConfig()->getConfigParam('sCompileDir') . "/vardump.txt", "a");
if (is_resource($f)) { if (is_resource($f)) {
fwrite( $f, $out ); fwrite($f, $out);
fclose( $f ); fclose($f);
} }
} else { } else {
if (!isAdmin()) { if (!isAdmin()) {
@ -103,4 +103,4 @@ function debugVar($mVar, bool $blToFile = false): void
dumpVar($mVar, $blToFile); dumpVar($mVar, $blToFile);
} }
} }
} }

View File

@ -37,7 +37,7 @@ $aModule = [
'url' => 'https://www.oxidmodule.com/', 'url' => 'https://www.oxidmodule.com/',
'controllers' => [], 'controllers' => [],
'extend' => [ 'extend' => [
ShopControl::class => ShopControl_DebugBar::class ShopControl::class => ShopControl_DebugBar::class,
], ],
'events' => [], 'events' => [],
'templates' => [], 'templates' => [],