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>
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
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 @@
/**
* 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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line either must return the controller object or throws an exception, if no subject is present. Therefore the whole nullable checks are not needed anymore.

$request = $controller ? $controller->getRequest() : null;
$this->_data = [
'matchedRoute' => $request ? $request->getParam('_matchedRoute') : null,
'matchedRoute' => $controller->getRequest()->getParam('_matchedRoute'),

Check warning on line 50 in src/Panel/RoutesPanel.php

View check run for this annotation

Codecov / codecov/patch

src/Panel/RoutesPanel.php#L50

Added line #L50 was not covered by tests
];
}
}
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') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. 4.x allowed the ConnectionManager to hold connection instances which did not implement ConnectionInterface, for e.g. https://github.com/UseMuffin/Webservice/blob/6376dc722529d888c4750793f0b286a8acd9fd71/src/Datasource/Connection.php#L19.

Guess we killed that in 5.0 by adding ConnnectionInterface as return type for ConnectionManager::get().

continue;
}
$driver = $connection->getDriver();
Expand Down