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
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.11.9" installed="1.11.9" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.25.0" installed="5.25.0" location="./tools/psalm" copy="false"/>
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
</phive>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"require": {
"php": ">=8.1",
"cakephp/cakephp": "dev-5.next as 5.1.0",
"cakephp/cakephp": "^5.1",
"composer/composer": "^2.0",
"doctrine/sql-formatter": "^1.1.3"
},
Expand Down
21 changes: 16 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
parameters:
ignoreErrors:
-
message: "#^Method DebugKit\\\\Mailer\\\\Transport\\\\DebugKitTransport\\:\\:send\\(\\) should return array\\{headers\\: string, message\\: string\\} but returns array\\{headers\\: non\\-empty\\-array\\<string, string\\>, message\\: array\\{text\\: string, html\\: string\\}\\}\\.$#"
message: '#^Method DebugKit\\Mailer\\Transport\\DebugKitTransport\:\:send\(\) should return array\{headers\: string, message\: string\} but returns array\{headers\: non\-empty\-array\<string, string\>, message\: array\{text\: string, html\: string\}\}\.$#'
identifier: return.type
count: 1
path: src/Mailer/Transport/DebugKitTransport.php

-
message: "#^Parameter \\#1 \\$request of method DebugKit\\\\ToolbarService\\:\\:saveData\\(\\) expects Cake\\\\Http\\\\ServerRequest, Psr\\\\Http\\\\Message\\\\ServerRequestInterface given\\.$#"
message: '#^Parameter \#1 \$request of method DebugKit\\ToolbarService\:\:saveData\(\) expects Cake\\Http\\ServerRequest, Psr\\Http\\Message\\ServerRequestInterface given\.$#'
identifier: argument.type
count: 1
path: src/Middleware/DebugKitMiddleware.php

-
message: "#^Call to an undefined method Cake\\\\ORM\\\\Locator\\\\LocatorInterface\\:\\:genericInstances\\(\\)\\.$#"
message: '#^PHPDoc tag @property for property DebugKit\\Model\\Table\\PanelsTable\:\:\$Requests contains unresolvable type\.$#'
identifier: propertyTag.unresolvableType
count: 1
path: src/Model/Table/PanelsTable.php

-
message: '#^Call to an undefined method Cake\\ORM\\Locator\\LocatorInterface\:\:genericInstances\(\)\.$#'
identifier: method.notFound
count: 1
path: src/Panel/SqlLogPanel.php

-
message: "#^Dead catch \\- Cake\\\\Core\\\\Exception\\\\CakeException is never thrown in the try block\\.$#"
message: '#^Dead catch \- Cake\\Core\\Exception\\CakeException is never thrown in the try block\.$#'
identifier: catch.neverThrown
count: 1
path: src/ToolbarService.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
message: '#^Unreachable statement \- code above always terminates\.$#'
identifier: deadCode.unreachable
count: 1
path: src/ToolbarService.php
102 changes: 18 additions & 84 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.20.0@3f284e96c9d9be6fe6b15c79416e1d1903dcfef4">
<file src="src/Cache/Engine/DebugEngine.php">
<RiskyTruthyFalsyComparison>
<code>$key</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Controller/MailPreviewController.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[$this->findPart($email, $partType)]]></code>
</RiskyTruthyFalsyComparison>
</file>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<file src="src/Database/Log/DebugLog.php">
<InternalMethod>
<code>jsonSerialize</code>
<code><![CDATA[jsonSerialize]]></code>
</InternalMethod>
</file>
<file src="src/DebugInclude.php">
Expand All @@ -21,119 +11,63 @@
<code><![CDATA[$this->_pluginPaths]]></code>
</PossiblyNullArrayOffset>
</file>
<file src="src/DebugMemory.php">
<RiskyTruthyFalsyComparison>
<code>!$message</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/DebugSql.php">
<InternalMethod>
<code>bindings</code>
<code><![CDATA[bindings]]></code>
</InternalMethod>
<RiskyTruthyFalsyComparison>
<code>$file</code>
<code>$file</code>
<code>$file</code>
<code>$line</code>
<code>$line</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/DebugTimer.php">
<PossiblyNullArrayOffset>
<code>self::$_timers</code>
<code><![CDATA[self::$_timers]]></code>
</PossiblyNullArrayOffset>
<RiskyTruthyFalsyComparison>
<code>!$message</code>
<code>!$name</code>
<code>!$name</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Mailer/MailPreview.php">
<PossiblyFalseOperand>
<code>$pos</code>
<code><![CDATA[$pos]]></code>
</PossiblyFalseOperand>
</file>
<file src="src/Mailer/PreviewResult.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[!$mailer->viewBuilder()->getTemplate()]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Mailer/Transport/DebugKitTransport.php">
<InvalidReturnStatement>
<code>$result</code>
<code><![CDATA[$result]]></code>
</InvalidReturnStatement>
<MoreSpecificReturnType>
<code>array</code>
<code><![CDATA[array]]></code>
</MoreSpecificReturnType>
<NullArgument>
<code><![CDATA[$this->emailLog]]></code>
</NullArgument>
</file>
<file src="src/Model/Table/LazyTableTrait.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[strpos($e->getMessage(), 'unable to open')]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Panel/DeprecationsPanel.php">
<RiskyTruthyFalsyComparison>
<code>$pluginName</code>
<code>$vendorName</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Panel/EnvironmentPanel.php">
<RiskyTruthyFalsyComparison>
<code>$pluginName</code>
<code>$vendorName</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Panel/IncludePanel.php">
<RiskyTruthyFalsyComparison>
<code>$pluginName</code>
<code>$vendorName</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Panel/LogPanel.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[Log::getConfig('debug_kit_log_panel')]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Panel/PanelRegistry.php">
<LessSpecificImplementedReturnType>
<code>string|null</code>
<code><![CDATA[string|null]]></code>
</LessSpecificImplementedReturnType>
<UnsafeInstantiation>
<code>new $class($this, $config)</code>
<code><![CDATA[new $class($this, $config)]]></code>
</UnsafeInstantiation>
</file>
<file src="src/Panel/PluginsPanel.php">
<InternalClass>
<code>PluginConfig::getAppConfig()</code>
<code><![CDATA[PluginConfig::getAppConfig()]]></code>
</InternalClass>
<InternalMethod>
<code>PluginConfig::getAppConfig()</code>
<code><![CDATA[PluginConfig::getAppConfig()]]></code>
</InternalMethod>
</file>
<file src="src/Panel/SqlLogPanel.php">
<UndefinedInterfaceMethod>
<code>genericInstances</code>
<code><![CDATA[genericInstances]]></code>
</UndefinedInterfaceMethod>
</file>
<file src="src/ToolbarService.php">
<RiskyTruthyFalsyComparison>
<code><![CDATA[!$GLOBALS['FORCE_DEBUGKIT_TOOLBAR']]]></code>
<code>$enabled</code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/View/Helper/ToolbarHelper.php">
<InternalClass>
<code>new HtmlFormatter()</code>
<code>new HtmlFormatter()</code>
<code><![CDATA[new HtmlFormatter()]]></code>
<code><![CDATA[new HtmlFormatter()]]></code>
</InternalClass>
<InternalMethod>
<code>dump</code>
<code>dump</code>
<code>new HtmlFormatter()</code>
<code>new HtmlFormatter()</code>
<code><![CDATA[dump]]></code>
<code><![CDATA[dump]]></code>
<code><![CDATA[new HtmlFormatter()]]></code>
<code><![CDATA[new HtmlFormatter()]]></code>
</InternalMethod>
</file>
</files>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
<RiskyTruthyFalsyComparison errorLevel="info" />
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Controller/MailPreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ protected function findPreview(string $previewName, string $emailName, string $p
$plugin = "$plugin.";
}

/** @var \DebugKit\Mailer\MailPreview $realClass */
$realClass = App::className($plugin . $previewName, 'Mailer/Preview');
if (!$realClass) {
throw new NotFoundException("Mailer preview $previewName not found");
}
/** @var \DebugKit\Mailer\MailPreview $mailPreview */
$mailPreview = new $realClass();

$email = $mailPreview->find($emailName);
Expand Down
2 changes: 1 addition & 1 deletion src/DebugPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function initialize(): void
/**
* Shutdown callback
*
* @param \Cake\Event\EventInterface $event The event.
* @param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event The event.
* @return void
*/
public function shutdown(EventInterface $event): void
Expand Down
8 changes: 7 additions & 1 deletion src/Panel/EnvironmentPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected function _prepare(): array
'error_reporting' => ini_get('error_reporting'),
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
'zend.assertions' => ini_get('zend.assertions'),
];

// CakePHP Data
Expand Down Expand Up @@ -90,8 +91,13 @@ protected function _prepare(): array
$var = get_defined_constants(true);
$return['app'] = array_diff_key($var['user'], $return['cake'], $hiddenCakeConstants);

$includePaths = $this->_debug->includePaths();
foreach ($includePaths as $k => $v) {
$includePaths[$k] = Debugger::exportVarAsNodes($v);
}

// Included files data
$return['includePaths'] = $this->_debug->includePaths();
$return['includePaths'] = $includePaths;
$return['includedFiles'] = $this->prepareIncludedFiles();

return $return;
Expand Down
6 changes: 2 additions & 4 deletions src/Panel/RoutesPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ public function summary(): string
/**
* Data collection callback.
*
* @param \Cake\Event\EventInterface $event The shutdown event.
* @param \Cake\Event\EventInterface<\Cake\Controller\Controller> $event The shutdown event.
* @return void
*/
public function shutdown(EventInterface $event): void
{
/** @var \Cake\Controller\Controller|null $controller */
$controller = $event->getSubject();
$request = $controller ? $controller->getRequest() : null;
$this->_data = [
'matchedRoute' => $request ? $request->getParam('_matchedRoute') : null,
'matchedRoute' => $controller->getRequest()->getParam('_matchedRoute'),
];
}
}
6 changes: 1 addition & 5 deletions src/Panel/SqlLogPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Cake\Core\Configure;
use Cake\Database\Driver;
use Cake\Datasource\ConnectionInterface;
use Cake\Datasource\ConnectionManager;
use Cake\ORM\Locator\LocatorAwareTrait;
use Cake\ORM\Table;
Expand Down Expand Up @@ -52,10 +51,7 @@ public function initialize(): void

foreach ($configs as $name) {
$connection = ConnectionManager::get($name);
if (
$connection->configName() === 'debug_kit'
|| !$connection instanceof ConnectionInterface
) {
if ($connection->configName() === 'debug_kit') {
continue;
}
$driver = $connection->getDriver();
Expand Down
7 changes: 7 additions & 0 deletions templates/element/environment_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
<div class="c-environment-panel">
<h2>CakePHP Version: <?= Configure::version() ?></h2>

<?php if (ini_get('zend.assertions') !== '1') : ?>
<div class="c-flash c-flash--warning">
You should set <code>zend.assertions</code> to <code>1</code>
in your <code>php.ini</code> for your development environment.
</div>
<?php endif; ?>

<h3>Application Constants</h3>

<?php if (!empty($app)) : ?>
Expand Down
8 changes: 2 additions & 6 deletions webroot/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,9 @@ strong {
text-align: left;
}

/* Override styles in cake's default css */
.c-debug-table .cake-debug-string {
margin-right: 48px;
}
/* correct height to fit with environment panel */
.c-debug-table .cake-debug-copy {
padding: 5px 6px;
position: static;
margin-left: 10px;
}

.c-debug-table .duplicate-route td {
Expand Down
Loading