Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,56 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<files psalm-version="5.10.0@a5effd2d2dddd1a7ea7a0f6a051ce63ff979e356">
<file src="src/DebugInclude.php">
<PossiblyNullArrayOffset occurrences="2">
<code>$this-&gt;_composerPaths</code>
<code>$this-&gt;_pluginPaths</code>
<PossiblyNullArrayOffset>
<code><![CDATA[$this->_composerPaths]]></code>
<code><![CDATA[$this->_pluginPaths]]></code>
</PossiblyNullArrayOffset>
</file>
<file src="src/DebugSql.php">
<InternalMethod occurrences="1">
<InternalMethod>
<code>bindings</code>
</InternalMethod>
</file>
<file src="src/DebugTimer.php">
<PossiblyNullArrayOffset occurrences="1">
<PossiblyNullArrayOffset>
<code>self::$_timers</code>
</PossiblyNullArrayOffset>
</file>
<file src="src/Mailer/MailPreview.php">
<PossiblyFalseOperand occurrences="1">
<PossiblyFalseOperand>
<code>$pos</code>
</PossiblyFalseOperand>
</file>
<file src="src/Mailer/Transport/DebugKitTransport.php">
<InvalidReturnStatement occurrences="1">
<InvalidReturnStatement>
<code>$result</code>
</InvalidReturnStatement>
<MoreSpecificReturnType occurrences="1">
<MoreSpecificReturnType>
<code>array</code>
</MoreSpecificReturnType>
<PropertyTypeCoercion occurrences="1">
<PropertyTypeCoercion>
<code>new $className($config)</code>
</PropertyTypeCoercion>
</file>
<file src="src/Panel/PanelRegistry.php">
<LessSpecificImplementedReturnType occurrences="1">
<LessSpecificImplementedReturnType>
<code>string|null</code>
</LessSpecificImplementedReturnType>
<UnsafeInstantiation occurrences="1">
<UnsafeInstantiation>
<code>new $class($this, $config)</code>
</UnsafeInstantiation>
</file>
<file src="src/Panel/SqlLogPanel.php">
<UndefinedInterfaceMethod occurrences="1">
<UndefinedInterfaceMethod>
<code>genericInstances</code>
</UndefinedInterfaceMethod>
</file>
<file src="src/View/Helper/ToolbarHelper.php">
<InternalClass occurrences="1">
<InternalClass>
<code>new HtmlFormatter()</code>
<code>new HtmlFormatter()</code>
</InternalClass>
<InternalMethod occurrences="1">
<InternalMethod>
<code>dump</code>
<code>dump</code>
<code>new HtmlFormatter()</code>
<code>new HtmlFormatter()</code>
</InternalMethod>
</file>
</files>
2 changes: 1 addition & 1 deletion src/Controller/PanelsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function index(?string $requestId = null): void
public function view(?string $id = null): void
{
$this->set('sort', $this->request->getCookie('debugKit_sort'));
$panel = $this->Panels->get($id, ['contain' => ['Requests']]);
$panel = $this->Panels->get($id, ...['contain' => ['Requests']]);

$this->set('panel', $panel);
// @codingStandardsIgnoreStart
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Table/PanelsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* each request.
*
* @property \DebugKit\Model\Table\RequestsTable&\Cake\ORM\Association\BelongsTo $Requests
* @method \DebugKit\Model\Entity\Panel get($primaryKey, $options = [])
* @method \DebugKit\Model\Entity\Panel get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, ...$args)
* @method \DebugKit\Model\Entity\Panel newEntity($data = null, array $options = [])
* @method \DebugKit\Model\Entity\Panel[] newEntities(array $data, array $options = [])
* @method \DebugKit\Model\Entity\Panel|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Table/RequestsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* The requests table tracks basic information about each request.
*
* @property \DebugKit\Model\Table\PanelsTable $Panels
* @method \DebugKit\Model\Entity\Request get($primaryKey, $options = [])
* @method \DebugKit\Model\Entity\Request get(mixed $primaryKey, array|string $finder = 'all', \Psr\SimpleCache\CacheInterface|string|null $cache = null, \Closure|string|null $cacheKey = null, ...$args)
* @method \DebugKit\Model\Entity\Request newEntity($data = null, array $options = [])
* @method \DebugKit\Model\Entity\Request[] newEntities(array $data, array $options = [])
* @method \DebugKit\Model\Entity\Request save(\Cake\Datasource\EntityInterface $entity, $options = [])
Expand Down
5 changes: 5 additions & 0 deletions src/Panel/IncludePanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
namespace DebugKit\Panel;

use Cake\Error\Debugger;
use Cake\Event\EventInterface;
use Cake\Utility\Hash;
use DebugKit\DebugInclude;
Expand Down Expand Up @@ -85,6 +86,10 @@ protected function _prepare(): array
ksort($plugin);
}

foreach ($return as $k => $v) {
$return[$k] = Debugger::exportVarAsNodes($v);
}

return $return;
}

Expand Down
17 changes: 11 additions & 6 deletions src/Panel/RequestPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
namespace DebugKit\Panel;

use Cake\Error\Debugger;
use Cake\Event\EventInterface;
use DebugKit\DebugPanel;
use Exception;
Expand Down Expand Up @@ -42,17 +43,21 @@ public function shutdown(EventInterface $event): void
} catch (Exception $e) {
$value = "Could not serialize `{$attr}`. It failed with {$e->getMessage()}";
}
$attributes[$attr] = $value;
$attributes[$attr] = Debugger::exportVarAsNodes($value);
}

$this->_data = [
'attributes' => $attributes,
'query' => $request->getQueryParams(),
'data' => $request->getData(),
'cookie' => $request->getCookieParams(),
'get' => $_GET,
'query' => Debugger::exportVarAsNodes($request->getQueryParams()),
'data' => Debugger::exportVarAsNodes($request->getData()),
'cookie' => Debugger::exportVarAsNodes($request->getCookieParams()),
'get' => Debugger::exportVarAsNodes($_GET),
'matchedRoute' => $request->getParam('_matchedRoute'),
'headers' => ['response' => headers_sent($file, $line), 'file' => $file, 'line' => $line],
'headers' => [
'response' => headers_sent($file, $line),
'file' => $file,
'line' => $line,
],
];
}
}
4 changes: 3 additions & 1 deletion src/Panel/SessionPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
namespace DebugKit\Panel;

use Cake\Error\Debugger;
use Cake\Event\EventInterface;
use DebugKit\DebugPanel;

Expand All @@ -33,7 +34,8 @@ public function shutdown(EventInterface $event): void
/** @var \Cake\Http\ServerRequest|null $request */
$request = $event->getSubject()->getRequest();
if ($request) {
$this->_data = ['content' => $request->getSession()->read()];
$content = Debugger::exportVarAsNodes($request->getSession()->read());
$this->_data = compact('content');
}
}
}
4 changes: 2 additions & 2 deletions src/Panel/VariablesPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public function shutdown(EventInterface $event): void
foreach ($vars as $k => $v) {
// Get the validation errors for Entity
if ($v instanceof EntityInterface) {
$errors[$k] = $this->_getErrors($v);
$errors[$k] = Debugger::exportVarAsNodes($this->_getErrors($v), $varsMaxDepth);
} elseif ($v instanceof Form) {
$formErrors = $v->getErrors();
if ($formErrors) {
$errors[$k] = $formErrors;
$errors[$k] = Debugger::exportVarAsNodes($formErrors, $varsMaxDepth);
}
}
$content[$k] = Debugger::exportVarAsNodes($v, $varsMaxDepth);
Expand Down
33 changes: 8 additions & 25 deletions src/View/Helper/ToolbarHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use Cake\Error\Debug\ArrayItemNode;
use Cake\Error\Debug\ArrayNode;
use Cake\Error\Debug\HtmlFormatter;
use Cake\Error\Debug\NodeInterface;
use Cake\Error\Debug\ScalarNode;
use Cake\Error\Debugger;
use Cake\View\Helper;

/**
Expand Down Expand Up @@ -66,7 +66,6 @@ public function setSort(bool $sort): void
*/
public function dumpNodes(array $nodes): string
{
/** @psalm-suppress InternalMethod */
$formatter = new HtmlFormatter();
if ($this->sort) {
ksort($nodes);
Expand All @@ -78,41 +77,25 @@ public function dumpNodes(array $nodes): string
$root = new ArrayNode($items);

return implode([
'<div class="cake-debug-output cake-debug" style="direction:ltr">',
'<div class="cake-debug-output" style="direction:ltr">',
$formatter->dump($root),
'</div>',
]);
}

/**
* Dump the value in $value into an interactive HTML output.
* Dump an error node
*
* @param mixed $value The value to output.
* @param \Cake\Error\Debug\NodeInterface $node A error node containing dumped variables.
* @return string Formatted HTML
* @deprecated 4.4.0
*/
public function dump(mixed $value): string
public function dumpNode(NodeInterface $node): string
{
$debugger = Debugger::getInstance();
$exportFormatter = $debugger->getConfig('exportFormatter');
$restore = false;
if ($exportFormatter !== HtmlFormatter::class) {
$restore = true;
$debugger->setConfig('exportFormatter', HtmlFormatter::class);
}

if ($this->sort && is_array($value)) {
ksort($value);
}

$contents = Debugger::exportVar($value, 25);
if ($restore) {
$debugger->setConfig('exportFormatter', $exportFormatter);
}
$formatter = new HtmlFormatter();

return implode([
'<div class="cake-debug-output cake-debug" style="direction:ltr">',
$contents,
'<div class="cake-debug-output" style="direction:ltr">',
$formatter->dump($node),
'</div>',
]);
}
Expand Down
16 changes: 8 additions & 8 deletions templates/element/include_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

/**
* @var \DebugKit\View\AjaxView $this
* @var array $paths
* @var array $app
* @var array $cake
* @var array $plugins
* @var array $vendor
* @var array $other
* @var array<\Cake\Error\Debug\NodeInterface> $paths
* @var array<\Cake\Error\Debug\NodeInterface> $app
* @var array<\Cake\Error\Debug\NodeInterface> $cake
* @var array<\Cake\Error\Debug\NodeInterface> $plugins
* @var array<\Cake\Error\Debug\NodeInterface> $vendor
* @var array<\Cake\Error\Debug\NodeInterface> $other
*/

// Backwards compat for old DebugKit data.
Expand All @@ -29,8 +29,8 @@
?>
<div class="c-include-panel">
<h4>Include Paths</h4>
<?= $this->Toolbar->dump($paths) ?>
<?= $this->Toolbar->dumpNodes(compact('paths')) ?>

<h4>Included Files</h4>
<?= $this->Toolbar->dump(compact('app', 'cake', 'plugins', 'vendor', 'other')) ?>
<?= $this->Toolbar->dumpNodes(compact('app', 'cake', 'plugins', 'vendor', 'other')) ?>
</div>
19 changes: 11 additions & 8 deletions templates/element/request_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
* @var \DebugKit\View\AjaxView $this
* @var array $headers
* @var array $attributes
* @var array $data
* @var array $query
* @var array $cookie
* @var \Cake\Error\Debug\NodeInterface $data
* @var \Cake\Error\Debug\NodeInterface $query
* @var \Cake\Error\Debug\NodeInterface $cookie
* @var string $matchedRoute
*/

use Cake\Error\Debugger;

?>
<div class="c-request-panel">
<?php if (!empty($headers) && $headers['response']) : ?>
Expand All @@ -43,7 +46,7 @@
if (empty($attributes)) :
echo '<p class="c-flash c-flash--info">No attributes data.</p>';
else :
echo $this->Toolbar->dump($attributes);
echo $this->Toolbar->dumpNodes($attributes);
endif;
?>

Expand All @@ -52,7 +55,7 @@
if (empty($data)) :
echo '<p class="c-flash c-flash--info">No post data.</p>';
else :
echo $this->Toolbar->dump($data);
echo $this->Toolbar->dumpNode($data);
endif;
?>

Expand All @@ -61,19 +64,19 @@
if (empty($query)) :
echo '<p class="c-flash c-flash--info">No querystring data.</p>';
else :
echo $this->Toolbar->dump($query);
echo $this->Toolbar->dumpNode($query);
endif;
?>

<h4>Cookie</h4>
<?php if (isset($cookie)) : ?>
<?= $this->Toolbar->dump($cookie) ?>
<?= $this->Toolbar->dumpNode($cookie) ?>
<?php else : ?>
<p class="c-flash c-flash--info">No Cookie data.</p>
<?php endif; ?>

<?php if (!empty($matchedRoute)) : ?>
<h4>Matched Route</h4>
<p><?= $this->Toolbar->dump(['template' => $matchedRoute]) ?></p>
<p><?= $this->Toolbar->dumpNode(Debugger::exportVarAsNodes(['template' => $matchedRoute])) ?></p>
<?php endif; ?>
</div>
4 changes: 2 additions & 2 deletions templates/element/session_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

/**
* @var \DebugKit\View\AjaxView $this
* @var array $content
* @var \Cake\Error\Debug\NodeInterface $content
*/
?>
<div class="c-session-panel">
<?= $this->Toolbar->dump($content) ?>
<?= $this->Toolbar->dumpNode($content) ?>
</div>
19 changes: 1 addition & 18 deletions templates/element/variables_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @var string $error
* @var bool|null $sort
* @var array $variables
* @var array $content
* @var array $errors
*/
?>
Expand All @@ -34,22 +33,6 @@
printf('<p class="c-flash c-flash--info">%s</p>', $msg);
}

// Backwards compatibility for old debug kit data.
if (!empty($content)) :?>
<div class="o-checkbox">
<label>
<input
type="checkbox"
class="js-debugkit-sort-variables"
<?= $sort ? ' checked="checked"' : '' ?>>
Sort variables by name
</label>
</div>
<?php
$this->Toolbar->setSort($sort);
echo $this->Toolbar->dump($content);
endif;

// New node based data.
if (!empty($variables)) :?>
<div class="o-checkbox">
Expand All @@ -68,7 +51,7 @@ class="js-debugkit-sort-variables"

if (!empty($errors)) :
echo '<h4>Validation errors</h4>';
echo $this->Toolbar->dump($errors);
echo $this->Toolbar->dumpNodes($errors);
endif;
?>
</div>
Loading