Skip to content

Commit ff083fb

Browse files
authored
Merge pull request #935 from cakephp/5.x-remove-deprecations
5.x: remove deprecations
2 parents 498fe00 + 9a80b63 commit ff083fb

19 files changed

Lines changed: 183 additions & 147 deletions

psalm-baseline.xml

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,60 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="4.x-dev@">
2+
<files psalm-version="5.10.0@a5effd2d2dddd1a7ea7a0f6a051ce63ff979e356">
33
<file src="src/DebugInclude.php">
4-
<PossiblyNullArrayOffset occurrences="2">
5-
<code>$this-&gt;_composerPaths</code>
6-
<code>$this-&gt;_pluginPaths</code>
4+
<PossiblyNullArrayOffset>
5+
<code><![CDATA[$this->_composerPaths]]></code>
6+
<code><![CDATA[$this->_pluginPaths]]></code>
77
</PossiblyNullArrayOffset>
88
</file>
99
<file src="src/DebugSql.php">
10-
<InternalMethod occurrences="1">
10+
<InternalMethod>
1111
<code>bindings</code>
1212
</InternalMethod>
1313
</file>
1414
<file src="src/DebugTimer.php">
15-
<PossiblyNullArrayOffset occurrences="1">
15+
<PossiblyNullArrayOffset>
1616
<code>self::$_timers</code>
1717
</PossiblyNullArrayOffset>
1818
</file>
1919
<file src="src/Mailer/MailPreview.php">
20-
<PossiblyFalseOperand occurrences="1">
20+
<PossiblyFalseOperand>
2121
<code>$pos</code>
2222
</PossiblyFalseOperand>
2323
</file>
2424
<file src="src/Mailer/Transport/DebugKitTransport.php">
25-
<InvalidReturnStatement occurrences="1">
25+
<InvalidReturnStatement>
2626
<code>$result</code>
2727
</InvalidReturnStatement>
28-
<MoreSpecificReturnType occurrences="1">
28+
<MoreSpecificReturnType>
2929
<code>array</code>
3030
</MoreSpecificReturnType>
31-
<PropertyTypeCoercion occurrences="1">
31+
<PropertyTypeCoercion>
3232
<code>new $className($config)</code>
3333
</PropertyTypeCoercion>
3434
</file>
3535
<file src="src/Panel/PanelRegistry.php">
36-
<LessSpecificImplementedReturnType occurrences="1">
36+
<LessSpecificImplementedReturnType>
3737
<code>string|null</code>
3838
</LessSpecificImplementedReturnType>
39-
<UnsafeInstantiation occurrences="1">
39+
<UnsafeInstantiation>
4040
<code>new $class($this, $config)</code>
4141
</UnsafeInstantiation>
4242
</file>
4343
<file src="src/Panel/SqlLogPanel.php">
44-
<UndefinedInterfaceMethod occurrences="1">
44+
<UndefinedInterfaceMethod>
4545
<code>genericInstances</code>
4646
</UndefinedInterfaceMethod>
4747
</file>
4848
<file src="src/View/Helper/ToolbarHelper.php">
49-
<InternalClass occurrences="1">
49+
<InternalClass>
50+
<code>new HtmlFormatter()</code>
5051
<code>new HtmlFormatter()</code>
5152
</InternalClass>
52-
<InternalMethod occurrences="1">
53+
<InternalMethod>
54+
<code>dump</code>
5355
<code>dump</code>
56+
<code>new HtmlFormatter()</code>
57+
<code>new HtmlFormatter()</code>
5458
</InternalMethod>
5559
</file>
5660
</files>

src/Controller/PanelsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function index(?string $requestId = null): void
8383
public function view(?string $id = null): void
8484
{
8585
$this->set('sort', $this->request->getCookie('debugKit_sort'));
86-
$panel = $this->Panels->get($id, ['contain' => ['Requests']]);
86+
$panel = $this->Panels->get($id, ...['contain' => ['Requests']]);
8787

8888
$this->set('panel', $panel);
8989
// @codingStandardsIgnoreStart

src/Model/Table/PanelsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* each request.
2323
*
2424
* @property \DebugKit\Model\Table\RequestsTable&\Cake\ORM\Association\BelongsTo $Requests
25-
* @method \DebugKit\Model\Entity\Panel get($primaryKey, $options = [])
25+
* @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)
2626
* @method \DebugKit\Model\Entity\Panel newEntity($data = null, array $options = [])
2727
* @method \DebugKit\Model\Entity\Panel[] newEntities(array $data, array $options = [])
2828
* @method \DebugKit\Model\Entity\Panel|false save(\Cake\Datasource\EntityInterface $entity, $options = [])

src/Model/Table/RequestsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* The requests table tracks basic information about each request.
2626
*
2727
* @property \DebugKit\Model\Table\PanelsTable $Panels
28-
* @method \DebugKit\Model\Entity\Request get($primaryKey, $options = [])
28+
* @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)
2929
* @method \DebugKit\Model\Entity\Request newEntity($data = null, array $options = [])
3030
* @method \DebugKit\Model\Entity\Request[] newEntities(array $data, array $options = [])
3131
* @method \DebugKit\Model\Entity\Request save(\Cake\Datasource\EntityInterface $entity, $options = [])

src/Panel/IncludePanel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
namespace DebugKit\Panel;
1616

17+
use Cake\Error\Debugger;
1718
use Cake\Event\EventInterface;
1819
use Cake\Utility\Hash;
1920
use DebugKit\DebugInclude;
@@ -85,6 +86,10 @@ protected function _prepare(): array
8586
ksort($plugin);
8687
}
8788

89+
foreach ($return as $k => $v) {
90+
$return[$k] = Debugger::exportVarAsNodes($v);
91+
}
92+
8893
return $return;
8994
}
9095

src/Panel/RequestPanel.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
namespace DebugKit\Panel;
1616

17+
use Cake\Error\Debugger;
1718
use Cake\Event\EventInterface;
1819
use DebugKit\DebugPanel;
1920
use Exception;
@@ -42,17 +43,21 @@ public function shutdown(EventInterface $event): void
4243
} catch (Exception $e) {
4344
$value = "Could not serialize `{$attr}`. It failed with {$e->getMessage()}";
4445
}
45-
$attributes[$attr] = $value;
46+
$attributes[$attr] = Debugger::exportVarAsNodes($value);
4647
}
4748

4849
$this->_data = [
4950
'attributes' => $attributes,
50-
'query' => $request->getQueryParams(),
51-
'data' => $request->getData(),
52-
'cookie' => $request->getCookieParams(),
53-
'get' => $_GET,
51+
'query' => Debugger::exportVarAsNodes($request->getQueryParams()),
52+
'data' => Debugger::exportVarAsNodes($request->getData()),
53+
'cookie' => Debugger::exportVarAsNodes($request->getCookieParams()),
54+
'get' => Debugger::exportVarAsNodes($_GET),
5455
'matchedRoute' => $request->getParam('_matchedRoute'),
55-
'headers' => ['response' => headers_sent($file, $line), 'file' => $file, 'line' => $line],
56+
'headers' => [
57+
'response' => headers_sent($file, $line),
58+
'file' => $file,
59+
'line' => $line,
60+
],
5661
];
5762
}
5863
}

src/Panel/SessionPanel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
namespace DebugKit\Panel;
1616

17+
use Cake\Error\Debugger;
1718
use Cake\Event\EventInterface;
1819
use DebugKit\DebugPanel;
1920

@@ -33,7 +34,8 @@ public function shutdown(EventInterface $event): void
3334
/** @var \Cake\Http\ServerRequest|null $request */
3435
$request = $event->getSubject()->getRequest();
3536
if ($request) {
36-
$this->_data = ['content' => $request->getSession()->read()];
37+
$content = Debugger::exportVarAsNodes($request->getSession()->read());
38+
$this->_data = compact('content');
3739
}
3840
}
3941
}

src/Panel/VariablesPanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,11 @@ public function shutdown(EventInterface $event): void
9797
foreach ($vars as $k => $v) {
9898
// Get the validation errors for Entity
9999
if ($v instanceof EntityInterface) {
100-
$errors[$k] = $this->_getErrors($v);
100+
$errors[$k] = Debugger::exportVarAsNodes($this->_getErrors($v), $varsMaxDepth);
101101
} elseif ($v instanceof Form) {
102102
$formErrors = $v->getErrors();
103103
if ($formErrors) {
104-
$errors[$k] = $formErrors;
104+
$errors[$k] = Debugger::exportVarAsNodes($formErrors, $varsMaxDepth);
105105
}
106106
}
107107
$content[$k] = Debugger::exportVarAsNodes($v, $varsMaxDepth);

src/View/Helper/ToolbarHelper.php

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
use Cake\Error\Debug\ArrayItemNode;
1919
use Cake\Error\Debug\ArrayNode;
2020
use Cake\Error\Debug\HtmlFormatter;
21+
use Cake\Error\Debug\NodeInterface;
2122
use Cake\Error\Debug\ScalarNode;
22-
use Cake\Error\Debugger;
2323
use Cake\View\Helper;
2424

2525
/**
@@ -66,7 +66,6 @@ public function setSort(bool $sort): void
6666
*/
6767
public function dumpNodes(array $nodes): string
6868
{
69-
/** @psalm-suppress InternalMethod */
7069
$formatter = new HtmlFormatter();
7170
if ($this->sort) {
7271
ksort($nodes);
@@ -78,41 +77,25 @@ public function dumpNodes(array $nodes): string
7877
$root = new ArrayNode($items);
7978

8079
return implode([
81-
'<div class="cake-debug-output cake-debug" style="direction:ltr">',
80+
'<div class="cake-debug-output" style="direction:ltr">',
8281
$formatter->dump($root),
8382
'</div>',
8483
]);
8584
}
8685

8786
/**
88-
* Dump the value in $value into an interactive HTML output.
87+
* Dump an error node
8988
*
90-
* @param mixed $value The value to output.
89+
* @param \Cake\Error\Debug\NodeInterface $node A error node containing dumped variables.
9190
* @return string Formatted HTML
92-
* @deprecated 4.4.0
9391
*/
94-
public function dump(mixed $value): string
92+
public function dumpNode(NodeInterface $node): string
9593
{
96-
$debugger = Debugger::getInstance();
97-
$exportFormatter = $debugger->getConfig('exportFormatter');
98-
$restore = false;
99-
if ($exportFormatter !== HtmlFormatter::class) {
100-
$restore = true;
101-
$debugger->setConfig('exportFormatter', HtmlFormatter::class);
102-
}
103-
104-
if ($this->sort && is_array($value)) {
105-
ksort($value);
106-
}
107-
108-
$contents = Debugger::exportVar($value, 25);
109-
if ($restore) {
110-
$debugger->setConfig('exportFormatter', $exportFormatter);
111-
}
94+
$formatter = new HtmlFormatter();
11295

11396
return implode([
114-
'<div class="cake-debug-output cake-debug" style="direction:ltr">',
115-
$contents,
97+
'<div class="cake-debug-output" style="direction:ltr">',
98+
$formatter->dump($node),
11699
'</div>',
117100
]);
118101
}

templates/element/include_panel.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
/**
1616
* @var \DebugKit\View\AjaxView $this
17-
* @var array $paths
18-
* @var array $app
19-
* @var array $cake
20-
* @var array $plugins
21-
* @var array $vendor
22-
* @var array $other
17+
* @var array<\Cake\Error\Debug\NodeInterface> $paths
18+
* @var array<\Cake\Error\Debug\NodeInterface> $app
19+
* @var array<\Cake\Error\Debug\NodeInterface> $cake
20+
* @var array<\Cake\Error\Debug\NodeInterface> $plugins
21+
* @var array<\Cake\Error\Debug\NodeInterface> $vendor
22+
* @var array<\Cake\Error\Debug\NodeInterface> $other
2323
*/
2424

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

3434
<h4>Included Files</h4>
35-
<?= $this->Toolbar->dump(compact('app', 'cake', 'plugins', 'vendor', 'other')) ?>
35+
<?= $this->Toolbar->dumpNodes(compact('app', 'cake', 'plugins', 'vendor', 'other')) ?>
3636
</div>

0 commit comments

Comments
 (0)