diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 7f6cfa305..2b9ed4bf6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -16,9 +16,9 @@ permissions:
jobs:
testsuite:
- uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@5.x
+ uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@6.x
secrets: inherit
cs-stan:
- uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x
+ uses: cakephp/.github/.github/workflows/cs-stan.yml@6.x
secrets: inherit
diff --git a/.phive/phars.xml b/.phive/phars.xml
index f648a9f74..21df37717 100644
--- a/.phive/phars.xml
+++ b/.phive/phars.xml
@@ -1,5 +1,5 @@
-
-
+
+
diff --git a/composer.json b/composer.json
index 38479ef2d..758fbcd00 100644
--- a/composer.json
+++ b/composer.json
@@ -28,15 +28,14 @@
"source": "https://github.com/cakephp/debug_kit"
},
"require": {
- "php": ">=8.1",
- "cakephp/cakephp": "^5.1",
+ "php": ">=8.4",
+ "cakephp/cakephp": "^6.0",
"composer/composer": "^2.7.7",
"doctrine/sql-formatter": "^1.1.3"
},
"require-dev": {
- "cakephp/authorization": "^3.0",
- "cakephp/cakephp-codesniffer": "^5.0",
- "phpunit/phpunit": "^10.5.32 || ^11.1.3 || ^12.0.9"
+ "cakephp/cakephp-codesniffer": "^6.0",
+ "phpunit/phpunit": "^12.1.3 || ^13.0"
},
"suggest": {
"ext-pdo_sqlite": "DebugKit needs to store panel data in a database. SQLite is simple and easy to use."
@@ -70,11 +69,11 @@
"stan-baseline": "tools/phpstan --generate-baseline",
"psalm-baseline": "tools/psalm --set-baseline=psalm-baseline.xml",
"stan-setup": "phive install",
- "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.3.1\" && mv composer.backup composer.json",
+ "rector-setup": "cp composer.json composer.backup && composer require --dev rector/rector:\"~2.6.0\" && mv composer.backup composer.json",
"rector-check": "vendor/bin/rector process --dry-run",
"rector-fix": "vendor/bin/rector process",
"test": "phpunit"
},
- "minimum-stability": "stable",
+ "minimum-stability": "dev",
"prefer-stable": true
}
diff --git a/config/bootstrap.php b/config/bootstrap.php
index 2afe7f8b5..306713ae5 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -50,7 +50,7 @@
* data in a browser-friendly way.
* @return \Cake\Database\Query
*/
- function sql(Query $query, $showValues = true, $showHtml = null)
+ function sql(Query $query, bool $showValues = true, ?bool $showHtml = null): Query
{
return DebugSql::sql($query, $showValues, $showHtml, 1);
}
@@ -69,7 +69,7 @@ function sql(Query $query, $showValues = true, $showHtml = null)
* data in a browser-friendly way.
* @return void
*/
- function sqld(Query $query, $showValues = true, $showHtml = null)
+ function sqld(Query $query, bool $showValues = true, ?bool $showHtml = null): void
{
DebugSql::sqld($query, $showValues, $showHtml, 2);
}
diff --git a/config/routes.php b/config/routes.php
index c3d73d68d..d3cefd071 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -4,53 +4,53 @@
use Cake\Routing\RouteBuilder;
return function (RouteBuilder $routes): void {
- $routes->plugin('DebugKit', ['path' => '/debug-kit'], function (RouteBuilder $routes): void {
+ $routes->plugin('DebugKit', callback: function (RouteBuilder $routes): void {
$routes->setExtensions('json');
$routes->setRouteClass(DashedRoute::class);
$routes->connect(
'/toolbar/clear-cache',
- ['controller' => 'Toolbar', 'action' => 'clearCache']
+ ['controller' => 'Toolbar', 'action' => 'clearCache'],
);
$routes->connect(
'/toolbar/clear-session',
- ['controller' => 'Toolbar', 'action' => 'clearSession']
+ ['controller' => 'Toolbar', 'action' => 'clearSession'],
);
$routes->connect(
'/toolbar/*',
- ['controller' => 'Requests', 'action' => 'view']
+ ['controller' => 'Requests', 'action' => 'view'],
);
$routes->connect(
'/panels/view/latest-history',
- ['controller' => 'Panels', 'action' => 'latestHistory']
+ ['controller' => 'Panels', 'action' => 'latestHistory'],
);
$routes->connect(
'/panels/view/*',
- ['controller' => 'Panels', 'action' => 'view']
+ ['controller' => 'Panels', 'action' => 'view'],
);
$routes->connect(
'/panels/*',
- ['controller' => 'Panels', 'action' => 'index']
+ ['controller' => 'Panels', 'action' => 'index'],
);
$routes->connect(
'/composer/check-dependencies',
- ['controller' => 'Composer', 'action' => 'checkDependencies']
+ ['controller' => 'Composer', 'action' => 'checkDependencies'],
);
$routes->scope(
'/mail-preview',
- ['controller' => 'MailPreview'],
- function (RouteBuilder $routes): void {
+ callback: function (RouteBuilder $routes): void {
$routes->connect('/', ['action' => 'index']);
$routes->connect('/preview', ['action' => 'email']);
$routes->connect('/preview/*', ['action' => 'email']);
$routes->connect('/sent/{panel}/{id}', ['action' => 'sent'], ['pass' => ['panel', 'id']]);
- }
+ },
+ params: ['controller' => 'MailPreview'],
);
$routes->get('/', ['controller' => 'Dashboard', 'action' => 'index']);
$routes->get('/dashboard', ['controller' => 'Dashboard', 'action' => 'index']);
$routes->post('/dashboard/reset', ['controller' => 'Dashboard', 'action' => 'reset']);
- });
+ }, params: ['path' => '/debug-kit']);
};
diff --git a/phpcs.xml b/phpcs.xml
index 114bdf842..6008bd737 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -1,11 +1,12 @@
+ config/
src/
tests/
-
+
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index ee142bcd7..482399950 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1,5 +1,17 @@
parameters:
ignoreErrors:
+ -
+ message: '#^Call to method skipAuthorization\(\) on an unknown class Authorization\\AuthorizationService\.$#'
+ identifier: class.notFound
+ count: 1
+ path: src/Controller/DebugKitController.php
+
+ -
+ message: '#^Class Authorization\\AuthorizationService not found\.$#'
+ identifier: class.notFound
+ count: 1
+ path: src/Controller/DebugKitController.php
+
-
message: '#^Parameter \#1 \$request of method DebugKit\\ToolbarService\:\:saveData\(\) expects Cake\\Http\\ServerRequest, Psr\\Http\\Message\\ServerRequestInterface given\.$#'
identifier: argument.type
@@ -12,6 +24,12 @@ parameters:
count: 1
path: src/Model/Table/PanelsTable.php
+ -
+ message: '#^Cannot call method getRequest\(\) on Cake\\Controller\\Controller\|null\.$#'
+ identifier: method.nonObject
+ count: 1
+ path: src/Panel/RoutesPanel.php
+
-
message: '#^Call to an undefined method Cake\\ORM\\Locator\\LocatorInterface\:\:genericInstances\(\)\.$#'
identifier: method.notFound
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index a0523438c..203cc1913 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -1,5 +1,15 @@
-
+
+
+
+
+
+
+
+
+
+
+
render()]]>
diff --git a/rector.php b/rector.php
index 724e2a670..dd88d05d9 100644
--- a/rector.php
+++ b/rector.php
@@ -2,26 +2,98 @@
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
-use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
+use Rector\CodeQuality\Rector\BooleanNot\NegatedAndsToPositiveOrsRector;
+use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector;
+use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
+use Rector\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector;
+use Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector;
+use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector;
+use Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector;
use Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector;
-use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector;
-use Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector;
+use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
+use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
+use Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector;
+use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
+use Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector;
+use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;
+use Rector\CodeQuality\Rector\Property\FixClassCaseSensitivityVarDocblockRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
+use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector;
+use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
+use Rector\CodingStyle\Rector\FuncCall\FunctionFirstClassCallableRector;
+use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector;
+use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
+use Rector\CodingStyle\Rector\String_\UseClassKeywordForClassNameResolutionRector;
use Rector\Config\RectorConfig;
+use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector;
+use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
+use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveDuplicatedReturnSelfDocblockRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveMixedDocblockOverruledByNativeTypeRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingClassMethodRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveReturnTagIncompatibleWithNativeTypeRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
-use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
+use Rector\DeadCode\Rector\ClassMethod\RemoveUselessUnionReturnDocblockRector;
+use Rector\DeadCode\Rector\ConstFetch\RemovePhpVersionIdCheckRector;
+use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector;
+use Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector;
+use Rector\DeadCode\Rector\For_\RemoveDeadLoopRector;
+use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
+use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
+use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector;
+use Rector\DeadCode\Rector\MethodCall\RemoveNullArgOnNullDefaultParamRector;
+use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
+use Rector\DeadCode\Rector\Property\RemoveDefaultValueFromAssignedPropertyRector;
+use Rector\DeadCode\Rector\Property\RemoveUselessVarTagRector;
+use Rector\DeadCode\Rector\StmtsAwareInterface\RemoveDeadInstanceOfAssertRector;
+use Rector\DeadCode\Rector\Ternary\RemoveUselessTernaryRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
+use Rector\Php56\Rector\FuncCall\PowToExpRector;
+use Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector;
+use Rector\Php73\Rector\FuncCall\SetCookieRector;
+use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
+use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
-use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
-use Rector\Php80\Rector\Class_\StringableForToStringRector;
+use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
+use Rector\Php80\Rector\FuncCall\ClassOnObjectRector;
+use Rector\Php80\Rector\NotIdentical\MbStrContainsRector;
+use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
+use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
+use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\Set\ValueObject\SetList;
-use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;
+use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
+use Rector\TypeDeclaration\Rector\BooleanAnd\BinaryOpNullableToInstanceofRector;
+use Rector\TypeDeclaration\Rector\Class_\TypedPropertyFromCreateMockAssignRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\AddParamStringTypeFromSprintfUseRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeBasedOnPHPUnitDataProviderRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\ArrayParamTypeByMethodCallTypeRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\BoolReturnTypeFromBooleanConstReturnsRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromMockObjectRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictFluentReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
-use Rector\TypeDeclaration\Rector\Function_\AddFunctionVoidReturnTypeWhereNoReturnRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\ReturnUnionTypeRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\ScalarParamTypeByMethodCallTypeRector;
+use Rector\TypeDeclaration\Rector\ClassMethod\StrictArrayParamDimFetchRector;
+use Rector\TypeDeclaration\Rector\Closure\AddClosureNeverReturnTypeRector;
+use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeFromAssertInstanceOfRector;
+use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
+use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeForArrayMapRector;
+use Rector\TypeDeclaration\Rector\FunctionLike\AddClosureParamTypeFromVariableCallRector;
+use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
+use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
+use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictSetUpRector;
+use Rector\TypeDeclaration\Rector\StmtsAwareInterface\SafeDeclareStrictTypesRector;
+use Rector\TypeDeclaration\Rector\While_\WhileNullableToInstanceofRector;
$cacheDir = getenv('RECTOR_CACHE_DIR') ?: sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'rector';
@@ -44,8 +116,6 @@
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
- SetList::EARLY_RETURN,
- SetList::INSTANCEOF,
SetList::TYPE_DECLARATION,
])
@@ -53,22 +123,106 @@
__DIR__ . '/tests/test_app/templates',
__DIR__ . '/tests/test_app/Plugin/TestPlugin/templates',
- ClassPropertyAssignToConstructorPromotionRector::class,
+ ThrowWithPreviousExceptionRector::class,
+ ExplicitReturnNullRector::class,
+ OptionalParametersAfterRequiredRector::class,
+ CompleteDynamicPropertiesRector::class,
+ ForeachToInArrayRector::class,
+ CompactToVariablesRector::class,
+ FlipTypeControlToUseExclusiveTypeRector::class,
+ ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class,
+ SimplifyIfReturnBoolRector::class,
+ AbsolutizeRequireAndIncludePathRector::class,
+ IssetOnPropertyObjectToPropertyExistsRector::class,
CatchExceptionNameMatchingTypeRector::class,
- ClosureToArrowFunctionRector::class,
+ CatchExceptionNameMatchingTypeRector::class,
+ MakeInheritedMethodVisibilitySameAsParentRector::class,
+ NewlineBeforeNewAssignSetRector::class,
+ StrictArraySearchRector::class,
+ VersionCompareFuncCallToConstantRector::class,
+ FunctionFirstClassCallableRector::class,
+ NewlineAfterStatementRector::class,
+ UseClassKeywordForClassNameResolutionRector::class,
+ RemoveDoubleAssignRector::class,
+ RemoveUnusedVariableAssignRector::class,
+ RecastingRemovalRector::class,
+ RemoveEmptyClassMethodRector::class,
+ RemoveNullTagValueNodeRector::class,
+ RemoveUnusedConstructorParamRector::class,
+ RemoveUnusedPrivateMethodRector::class,
+ RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
+ RemovePhpVersionIdCheckRector::class,
+ RemoveDeadStmtRector::class,
+ RemoveDeadIfForeachForRector::class,
+ RemoveDeadLoopRector::class,
+ RemoveAlwaysTrueIfConditionRector::class,
+ RemoveDeadInstanceOfRector::class,
+ UnwrapFutureCompatibleIfPhpVersionRector::class,
+ RemoveNullArgOnNullDefaultParamRector::class => [
+ __DIR__ . '/tests/TestCase/Database/Expression/QueryExpressionTest.php',
+ ],
+ RemoveNonExistingVarAnnotationRector::class,
+ RemoveUselessVarTagRector::class,
+ PowToExpRector::class,
+ ArrayKeyFirstLastRector::class,
+ SetCookieRector::class,
+ StringifyStrNeedlesRector::class,
+ SensitiveHereNowDocRector::class,
+ ClosureToArrowFunctionRector::class,
+ ReadOnlyPropertyRector::class,
+ AddArrowFunctionReturnTypeRector::class,
+ BinaryOpNullableToInstanceofRector::class,
+ NewlineBetweenClassLikeStmtsRector::class,
+ AddParamStringTypeFromSprintfUseRector::class,
+ AddParamTypeBasedOnPHPUnitDataProviderRector::class,
+ AddVoidReturnTypeWhereNoReturnRector::class,
+ BoolReturnTypeFromBooleanConstReturnsRector::class,
+ ParamTypeByMethodCallTypeRector::class,
+ ReturnNeverTypeRector::class,
+ ReturnTypeFromMockObjectRector::class,
ReturnTypeFromStrictFluentReturnRector::class,
- NewlineAfterStatementRector::class,
- StringClassNameToClassConstantRector::class,
ReturnTypeFromStrictTypedCallRector::class,
- ParamTypeByMethodCallTypeRector::class,
- AddFunctionVoidReturnTypeWhereNoReturnRector::class,
- StringableForToStringRector::class,
- CompactToVariablesRector::class,
- SplitDoubleAssignRector::class,
- ChangeOrIfContinueToMultiContinueRector::class,
- ExplicitBoolCompareRector::class,
- NewlineBeforeNewAssignSetRector::class,
- SimplifyEmptyCheckOnEmptyArrayRector::class,
- DisallowedEmptyRuleFixerRector::class,
+ ReturnUnionTypeRector::class,
+ StrictArrayParamDimFetchRector::class,
+ TypedPropertyFromCreateMockAssignRector::class,
+ AddClosureNeverReturnTypeRector::class,
+ ClosureReturnTypeRector::class,
+ TypedPropertyFromAssignsRector::class,
+ TypedPropertyFromStrictConstructorRector::class,
+ TypedPropertyFromStrictSetUpRector::class,
+ WhileNullableToInstanceofRector::class,
+ RestoreDefaultNullToNullableTypePropertyRector::class,
+
+ // Manual - only appliable for part of the code
+ UseIdenticalOverEqualWithSameTypeRector::class,
+ RemoveDeadStmtRector::class,
+ StringClassNameToClassConstantRector::class,
+ ArrayKeyFirstLastRector::class,
+ ClassOnObjectRector::class,
+
+ // Newly aggressive in rector 2.4 - keep the bump behavior-neutral:
+ // adds declare(strict_types=1) to test fixtures/config (out of scope here),
+ SafeDeclareStrictTypesRector::class,
+ // and rewrites `$x ?: []` in ways that can change behavior on undefined/empty values.
+ RemoveUselessTernaryRector::class,
+
+ // New in rector 2.5 - skipped to keep the version bump behavior-neutral.
+ // Together these touch ~226 files, mostly docblock removal. Whether to apply
+ // them is a separate decision from getting CI green again.
+ NegatedAndsToPositiveOrsRector::class,
+ FixClassCaseSensitivityVarDocblockRector::class,
+ RemoveDuplicatedReturnSelfDocblockRector::class,
+ RemoveMixedDocblockOverruledByNativeTypeRector::class,
+ RemoveParentDelegatingClassMethodRector::class,
+ RemoveReturnTagIncompatibleWithNativeTypeRector::class,
+ RemoveUselessUnionReturnDocblockRector::class,
+ RemoveDefaultValueFromAssignedPropertyRector::class,
+ RemoveDeadInstanceOfAssertRector::class,
+ MbStrContainsRector::class,
+ ArrayParamTypeByMethodCallTypeRector::class,
+ ScalarParamTypeByMethodCallTypeRector::class,
+ ClosureReturnTypeFromAssertInstanceOfRector::class,
+ AddClosureParamTypeForArrayMapRector::class,
+ AddClosureParamTypeFromVariableCallRector::class,
]);
diff --git a/src/Cache/Engine/DebugEngine.php b/src/Cache/Engine/DebugEngine.php
index 97b47359a..492d139ff 100644
--- a/src/Cache/Engine/DebugEngine.php
+++ b/src/Cache/Engine/DebugEngine.php
@@ -17,6 +17,7 @@
use Cake\Cache\CacheEngine;
use Cake\Cache\CacheRegistry;
use Psr\Log\LoggerInterface;
+use Stringable;
use function Cake\Core\namespaceSplit;
/**
@@ -24,16 +25,12 @@
*
* Used by the CachePanel to wrap and track metrics related to caching.
*/
-class DebugEngine extends CacheEngine
+class DebugEngine extends CacheEngine implements Stringable
{
/**
* Proxied engine
*/
- protected CacheEngine $_engine;
-
- protected LoggerInterface $logger;
-
- protected string $name;
+ protected CacheEngine $engine;
/**
* Hit/miss metrics.
@@ -54,16 +51,13 @@ class DebugEngine extends CacheEngine
* @param string $name The name of the proxied cache engine.
* @param \Psr\Log\LoggerInterface $logger Logger for collecting cache operation logs.
*/
- public function __construct(CacheEngine|array $config, string $name, LoggerInterface $logger)
+ public function __construct(CacheEngine|array $config, protected string $name, protected LoggerInterface $logger)
{
if ($config instanceof CacheEngine) {
- $this->_engine = $config;
+ $this->engine = $config;
} else {
- $this->_config = $config;
+ $this->config = $config;
}
-
- $this->logger = $logger;
- $this->name = $name;
}
/**
@@ -74,9 +68,9 @@ public function __construct(CacheEngine|array $config, string $name, LoggerInter
*/
public function init(array $config = []): bool
{
- if (!isset($this->_engine)) {
+ if (!isset($this->engine)) {
$registry = new CacheRegistry();
- $this->_engine = $registry->load('spies', $this->_config);
+ $this->engine = $registry->load('spies', $this->config);
unset($registry);
}
@@ -90,7 +84,7 @@ public function init(array $config = []): bool
*/
public function engine(): CacheEngine
{
- return $this->_engine;
+ return $this->engine;
}
/**
@@ -135,7 +129,7 @@ protected function log(string $operation, float $duration, ?string $key = null):
public function set($key, $value, $ttl = null): bool
{
$start = microtime(true);
- $result = $this->_engine->set($key, $value, $ttl);
+ $result = $this->engine->set($key, $value, $ttl);
$duration = microtime(true) - $start;
$this->track('set');
@@ -150,7 +144,7 @@ public function set($key, $value, $ttl = null): bool
public function add(string $key, mixed $value): bool
{
$start = microtime(true);
- $result = $this->_engine->add($key, $value);
+ $result = $this->engine->add($key, $value);
$duration = microtime(true) - $start;
$this->track('set');
@@ -165,7 +159,7 @@ public function add(string $key, mixed $value): bool
public function setMultiple($values, $ttl = null): bool
{
$start = microtime(true);
- $result = $this->_engine->setMultiple($values);
+ $result = $this->engine->setMultiple($values);
$duration = microtime(true) - $start;
$this->track('set');
@@ -180,7 +174,7 @@ public function setMultiple($values, $ttl = null): bool
public function get(string $key, mixed $default = null): mixed
{
$start = microtime(true);
- $result = $this->_engine->get($key, $default);
+ $result = $this->engine->get($key, $default);
$duration = microtime(true) - $start;
$metric = 'hit';
if ($result === null) {
@@ -199,7 +193,7 @@ public function get(string $key, mixed $default = null): mixed
public function has(string $key): bool
{
$start = microtime(true);
- $result = $this->_engine->has($key);
+ $result = $this->engine->has($key);
$duration = microtime(true) - $start;
$metric = 'hit';
if (!$result) {
@@ -218,7 +212,7 @@ public function has(string $key): bool
public function getMultiple($keys, $default = null): iterable
{
$start = microtime(true);
- $result = $this->_engine->getMultiple($keys, $default);
+ $result = $this->engine->getMultiple($keys, $default);
$duration = microtime(true) - $start;
$this->track('get hit');
@@ -233,7 +227,7 @@ public function getMultiple($keys, $default = null): iterable
public function increment(string $key, int $offset = 1): int|false
{
$start = microtime(true);
- $result = $this->_engine->increment($key, $offset);
+ $result = $this->engine->increment($key, $offset);
$duration = microtime(true) - $start;
$this->track('set');
@@ -248,7 +242,7 @@ public function increment(string $key, int $offset = 1): int|false
public function decrement(string $key, int $offset = 1): int|false
{
$start = microtime(true);
- $result = $this->_engine->decrement($key, $offset);
+ $result = $this->engine->decrement($key, $offset);
$duration = microtime(true) - $start;
$this->track('set');
@@ -263,7 +257,7 @@ public function decrement(string $key, int $offset = 1): int|false
public function delete($key): bool
{
$start = microtime(true);
- $result = $this->_engine->delete($key);
+ $result = $this->engine->delete($key);
$duration = microtime(true) - $start;
$this->track('delete');
@@ -278,7 +272,7 @@ public function delete($key): bool
public function deleteMultiple($keys): bool
{
$start = microtime(true);
- $result = $this->_engine->deleteMultiple($keys);
+ $result = $this->engine->deleteMultiple($keys);
$duration = microtime(true) - $start;
$this->track('delete');
@@ -293,7 +287,7 @@ public function deleteMultiple($keys): bool
public function clear(): bool
{
$start = microtime(true);
- $result = $this->_engine->clear();
+ $result = $this->engine->clear();
$duration = microtime(true) - $start;
$this->track('delete');
@@ -307,7 +301,7 @@ public function clear(): bool
*/
public function groups(): array
{
- return $this->_engine->groups();
+ return $this->engine->groups();
}
/**
@@ -319,7 +313,7 @@ public function groups(): array
*/
public function getConfig(?string $key = null, mixed $default = null): mixed
{
- return $this->_engine->getConfig($key, $default);
+ return $this->engine->getConfig($key, $default);
}
/**
@@ -331,9 +325,9 @@ public function getConfig(?string $key = null, mixed $default = null): mixed
* @return $this
* @throws \Cake\Core\Exception\CakeException When trying to set a key that is invalid.
*/
- public function setConfig(array|string $key, mixed $value = null, bool $merge = true)
+ public function setConfig(array|string $key, mixed $value = null, bool $merge = true): static
{
- $this->_engine->setConfig($key, $value, $merge);
+ $this->engine->setConfig($key, $value, $merge);
return $this;
}
@@ -344,7 +338,7 @@ public function setConfig(array|string $key, mixed $value = null, bool $merge =
public function clearGroup(string $group): bool
{
$start = microtime(true);
- $result = $this->_engine->clearGroup($group);
+ $result = $this->engine->clearGroup($group);
$duration = microtime(true) - $start;
$this->track('delete');
@@ -360,13 +354,13 @@ public function clearGroup(string $group): bool
*/
public function __toString(): string
{
- if (isset($this->_engine)) {
+ if (isset($this->engine)) {
// phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
- [$ns, $class] = namespaceSplit($this->_engine::class);
+ [$ns, $class] = namespaceSplit($this->engine::class);
return str_replace('Engine', '', $class);
}
- return $this->_config['className'];
+ return (string)$this->config['className'];
}
}
diff --git a/src/Command/BenchmarkCommand.php b/src/Command/BenchmarkCommand.php
index af7f23220..7f92b13f0 100644
--- a/src/Command/BenchmarkCommand.php
+++ b/src/Command/BenchmarkCommand.php
@@ -16,8 +16,6 @@
namespace DebugKit\Command;
use Cake\Command\Command;
-use Cake\Console\Arguments;
-use Cake\Console\ConsoleIo;
use Cake\Console\ConsoleOptionParser;
use Cake\Utility\Text;
@@ -39,34 +37,26 @@ public static function getDescription(): string
return 'Benchmark a fully qualified URL.';
}
- /**
- * The console io
- */
- protected ConsoleIo $io;
-
/**
* Execute.
*
- * @param \Cake\Console\Arguments $args The command arguments.
- * @param \Cake\Console\ConsoleIo $io The console io
* @return int|null The exit code or null for success
*/
- public function execute(Arguments $args, ConsoleIo $io): ?int
+ public function execute(): ?int
{
- $this->io = $io;
/** @var string $url */
- $url = $args->getArgumentAt(0);
+ $url = $this->args->getArgumentAt(0);
$times = [];
- $io->out(Text::insert('-> Testing :url', compact('url')));
- $io->out('');
+ $this->io->out(Text::insert('-> Testing :url', compact('url')));
+ $this->io->out('');
$count = 10;
- if ($args->hasOption('n')) {
- $count = (float)$args->getOption('n');
+ if ($this->args->hasOption('n')) {
+ $count = (float)$this->args->getOption('n');
}
$timeout = 100;
- if ($args->hasOption('t')) {
- $timeout = (float)$args->getOption('t');
+ if ($this->args->hasOption('t')) {
+ $timeout = (float)$this->args->getOption('t');
}
for ($i = 0; $i < $count; $i++) {
@@ -80,7 +70,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
$times[] = $stop - $start;
}
- $this->_results($times);
+ $this->results($times);
return static::CODE_SUCCESS;
}
@@ -91,7 +81,7 @@ public function execute(Arguments $args, ConsoleIo $io): ?int
* @param array $times Array of time values
* @return void
*/
- protected function _results(array $times): void
+ protected function results(array $times): void
{
$duration = array_sum($times);
$requests = count($times);
@@ -110,10 +100,10 @@ protected function _results(array $times): void
]));
$this->io->out(Text::insert('Standard deviation of average request time: :std-dev', [
- 'std-dev' => round($this->_deviation($times, true), 3),
+ 'std-dev' => round($this->deviation($times, true), 3),
]));
- if (!empty($times)) {
+ if ($times !== []) {
$this->io->out(Text::insert('Longest/shortest request: :longest sec/:shortest sec', [
'longest' => round(max($times), 3),
'shortest' => round(min($times), 3),
@@ -135,10 +125,11 @@ protected function _results(array $times): void
* variance from a finite sample.
* @return float Variance
*/
- protected function _variance(array $times, bool $sample = true): float
+ protected function variance(array $times, bool $sample = true): float
{
- $n = $mean = $M2 = 0;
-
+ $n = 0;
+ $mean = 0;
+ $M2 = 0;
foreach ($times as $time) {
$n += 1;
$delta = $time - $mean;
@@ -160,9 +151,9 @@ protected function _variance(array $times, bool $sample = true): float
* @param bool $sample ''
* @return float Standard deviation
*/
- protected function _deviation(array $times, bool $sample = true): float
+ protected function deviation(array $times, bool $sample = true): float
{
- return sqrt($this->_variance($times, $sample));
+ return sqrt($this->variance($times, $sample));
}
/**
diff --git a/src/Controller/ComposerController.php b/src/Controller/ComposerController.php
index 6697b07f2..1d3e72f2a 100644
--- a/src/Controller/ComposerController.php
+++ b/src/Controller/ComposerController.php
@@ -66,10 +66,10 @@ public function checkDependencies(): void
$bcBreaks[] = $dependency;
}
$packages = [];
- if ($semverCompatible) {
+ if ($semverCompatible !== []) {
$packages['semverCompatible'] = trim(implode("\n", $semverCompatible));
}
- if ($bcBreaks) {
+ if ($bcBreaks !== []) {
$packages['bcBreaks'] = trim(implode("\n", $bcBreaks));
}
diff --git a/src/Controller/PanelsController.php b/src/Controller/PanelsController.php
index 2aec295dc..d7ca93acd 100644
--- a/src/Controller/PanelsController.php
+++ b/src/Controller/PanelsController.php
@@ -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);
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
@@ -98,9 +98,8 @@ public function view(?string $id = null): void
public function latestHistory(): ?Response
{
/** @var array{id:string}|null $request */
- $request = $this->Panels->Requests->find('recent')
+ $request = $this->Panels->Requests->unhydratedFind('recent')
->select(['id'])
- ->disableHydration()
->first();
if (!$request) {
throw new NotFoundException('No requests found');
diff --git a/src/Database/Log/DebugLog.php b/src/Database/Log/DebugLog.php
index 7a56e23c8..f4c1af97d 100644
--- a/src/Database/Log/DebugLog.php
+++ b/src/Database/Log/DebugLog.php
@@ -32,28 +32,12 @@ class DebugLog extends AbstractLogger
/**
* Logs from the current request.
*/
- protected array $_queries = [];
-
- /**
- * Decorated logger.
- */
- protected ?LoggerInterface $_logger = null;
-
- /**
- * Name of the connection being logged.
- */
- protected string $_connectionName;
+ protected array $queries = [];
/**
* Total time (ms) of all queries
*/
- protected float $_totalTime = 0;
-
- /**
- * Set to true to capture schema reflection queries
- * in the SQL log panel.
- */
- protected bool $_includeSchema = false;
+ protected float $totalTime = 0;
/**
* Whether a transaction is currently open or not.
@@ -63,15 +47,15 @@ class DebugLog extends AbstractLogger
/**
* Constructor
*
- * @param \Psr\Log\LoggerInterface|null $logger The logger to decorate and spy on.
- * @param string $name The name of the connection being logged.
- * @param bool $includeSchema Whether or not schema reflection should be included.
+ * @param \Psr\Log\LoggerInterface|null $_logger The logger to decorate and spy on.
+ * @param string $_connectionName The name of the connection being logged.
+ * @param bool $_includeSchema Whether or not schema reflection should be included.
*/
- public function __construct(?LoggerInterface $logger, string $name, bool $includeSchema = false)
- {
- $this->_logger = $logger;
- $this->_connectionName = $name;
- $this->_includeSchema = $includeSchema;
+ public function __construct(
+ protected ?LoggerInterface $_logger,
+ protected string $_connectionName,
+ protected bool $_includeSchema = false,
+ ) {
}
/**
@@ -80,7 +64,7 @@ public function __construct(?LoggerInterface $logger, string $name, bool $includ
* @param bool $value Set
* @return $this
*/
- public function setIncludeSchema(bool $value)
+ public function setIncludeSchema(bool $value): static
{
$this->_includeSchema = $value;
@@ -104,7 +88,7 @@ public function name(): string
*/
public function queries(): array
{
- return $this->_queries;
+ return $this->queries;
}
/**
@@ -114,7 +98,7 @@ public function queries(): array
*/
public function totalTime(): float
{
- return $this->_totalTime;
+ return $this->totalTime;
}
/**
@@ -132,9 +116,9 @@ public function log($level, string|Stringable $message, array $context = []): vo
// This specific to Elastic Search
if (!$query instanceof LoggedQuery && isset($context['request']) && isset($context['response'])) {
$took = $context['response']['took'] ?? 0;
- $this->_totalTime += $took;
+ $this->totalTime += $took;
- $this->_queries[] = [
+ $this->queries[] = [
'query' => json_encode([
'method' => $context['request']['method'],
'path' => $context['request']['path'],
@@ -159,7 +143,7 @@ public function log($level, string|Stringable $message, array $context = []): vo
$data = $query->jsonSerialize();
- $this->_totalTime += $data['took'];
+ $this->totalTime += $data['took'];
$sql = (string)$query;
$isBegin = $sql === 'BEGIN';
@@ -169,7 +153,7 @@ public function log($level, string|Stringable $message, array $context = []): vo
$this->inTransaction = true;
}
- $this->_queries[] = [
+ $this->queries[] = [
'query' => $sql,
'took' => $data['took'],
'rows' => $data['numRows'],
diff --git a/src/DebugInclude.php b/src/DebugInclude.php
index 949859e75..f2a0541ab 100644
--- a/src/DebugInclude.php
+++ b/src/DebugInclude.php
@@ -28,19 +28,19 @@ class DebugInclude
*
* @var array
*/
- protected array $_pluginPaths = [];
+ protected array $pluginPaths = [];
/**
* The list of Composer packages
*
* @var array
*/
- protected array $_composerPaths = [];
+ protected array $composerPaths = [];
/**
* File Types
*/
- protected array $_fileTypes = [
+ protected array $fileTypes = [
'Auth', 'Cache', 'Collection', 'Config', 'Configure', 'Console', 'Component', 'Controller',
'Behavior', 'Database', 'Datasource', 'Model', 'Template', 'View', 'Utility',
'Network', 'Routing', 'I18n', 'Log', 'Error', 'Event', 'Form', 'Filesystem',
@@ -53,7 +53,7 @@ class DebugInclude
public function __construct()
{
foreach (CorePlugin::loaded() as $plugin) {
- $this->_pluginPaths[$plugin] = str_replace('/', DIRECTORY_SEPARATOR, CorePlugin::path($plugin));
+ $this->pluginPaths[$plugin] = str_replace('/', DIRECTORY_SEPARATOR, CorePlugin::path($plugin));
}
$lockFile = new JsonFile(ROOT . DIRECTORY_SEPARATOR . 'composer.lock');
@@ -66,7 +66,7 @@ public function __construct()
foreach ($packages as $package) {
/** @var string $name */
$name = $package['name'];
- $this->_composerPaths[$name] = $vendorDir
+ $this->composerPaths[$name] = $vendorDir
. str_replace('/', DIRECTORY_SEPARATOR, $name)
. DIRECTORY_SEPARATOR;
}
@@ -118,7 +118,7 @@ public function isAppFile(string $file): bool
*/
public function getPluginName(string $file): string|bool
{
- foreach ($this->_pluginPaths as $plugin => $path) {
+ foreach ($this->pluginPaths as $plugin => $path) {
if (str_starts_with($file, $path)) {
return $plugin;
}
@@ -135,7 +135,7 @@ public function getPluginName(string $file): string|bool
*/
public function getComposerPackageName(string $file): string|bool
{
- foreach ($this->_composerPaths as $package => $path) {
+ foreach ($this->composerPaths as $package => $path) {
if (str_starts_with($file, $path)) {
return $package;
}
@@ -158,8 +158,8 @@ public function niceFileName(string $file, string $type, ?string $name = null):
'app' => str_replace(APP, 'APP' . DIRECTORY_SEPARATOR, $file),
'cake' => str_replace(CAKE, 'CAKE' . DIRECTORY_SEPARATOR, $file),
'root' => str_replace(ROOT, 'ROOT', $file),
- 'plugin' => str_replace($this->_pluginPaths[$name], $name . DIRECTORY_SEPARATOR, $file),
- 'vendor' => str_replace($this->_composerPaths[$name], '', $file),
+ 'plugin' => str_replace($this->pluginPaths[$name], $name . DIRECTORY_SEPARATOR, $file),
+ 'vendor' => str_replace($this->composerPaths[$name], '', $file),
default => throw new InvalidArgumentException(sprintf('Type `%s` is not supported.', $type)),
};
}
@@ -172,7 +172,7 @@ public function niceFileName(string $file, string $type, ?string $name = null):
*/
public function getFileType(string $file): string
{
- foreach ($this->_fileTypes as $type) {
+ foreach ($this->fileTypes as $type) {
if (stripos($file, DIRECTORY_SEPARATOR . $type . DIRECTORY_SEPARATOR) !== false) {
return $type;
}
diff --git a/src/DebugKitPlugin.php b/src/DebugKitPlugin.php
index d9a25ba88..48a9c4068 100644
--- a/src/DebugKitPlugin.php
+++ b/src/DebugKitPlugin.php
@@ -102,7 +102,7 @@ public function setDeprecationHandler(ToolbarService $service): void
// Extract the line/file from the message as deprecationWarning
// will calculate the application frame when generating the message.
preg_match('/\\n([^\n,]+?), line: (\d+)\\n/', $error->getMessage(), $matches);
- if ($matches) {
+ if ($matches !== []) {
$file = $matches[1];
$line = $matches[2];
}
diff --git a/src/DebugMemory.php b/src/DebugMemory.php
index b944802da..08d02ed2c 100644
--- a/src/DebugMemory.php
+++ b/src/DebugMemory.php
@@ -25,7 +25,7 @@ class DebugMemory
/**
* An array of recorded memory use points.
*/
- protected static array $_points = [];
+ protected static array $points = [];
/**
* Get current memory usage
@@ -64,15 +64,15 @@ public static function record(?string $message = null): bool
$line = $trace[0]['line'] ?? 'n/a';
$message = Debugger::trimPath($file) . ' line ' . $line;
}
- if (isset(self::$_points[$message])) {
+ if (isset(self::$points[$message])) {
$originalMessage = $message;
$i = 1;
- while (isset(self::$_points[$message])) {
+ while (isset(self::$points[$message])) {
$i++;
$message = $originalMessage . ' #' . $i;
}
}
- self::$_points[$message] = $memoryUse;
+ self::$points[$message] = $memoryUse;
return true;
}
@@ -85,9 +85,9 @@ public static function record(?string $message = null): bool
*/
public static function getAll(bool $clear = false): array
{
- $marks = self::$_points;
+ $marks = self::$points;
if ($clear) {
- self::$_points = [];
+ self::$points = [];
}
return $marks;
@@ -100,6 +100,6 @@ public static function getAll(bool $clear = false): array
*/
public static function clear(): void
{
- self::$_points = [];
+ self::$points = [];
}
}
diff --git a/src/DebugPanel.php b/src/DebugPanel.php
index ef7571ee2..e40beab5b 100644
--- a/src/DebugPanel.php
+++ b/src/DebugPanel.php
@@ -35,7 +35,7 @@ class DebugPanel implements EventListenerInterface
/**
* The data collected about a given request.
*/
- protected array $_data = [];
+ protected array $data = [];
/**
* Get the title for the panel.
@@ -58,8 +58,7 @@ public function title(): string
*/
public function elementName(): string
{
- // phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
- [$ns, $name] = namespaceSplit(static::class);
+ [, $name] = namespaceSplit(static::class);
if ($this->plugin) {
return $this->plugin . '.' . Inflector::underscore($name);
}
@@ -74,7 +73,7 @@ public function elementName(): string
*/
public function data(): array
{
- return $this->_data;
+ return $this->data;
}
/**
diff --git a/src/DebugSql.php b/src/DebugSql.php
index 7d57db736..6d046ebc6 100644
--- a/src/DebugSql.php
+++ b/src/DebugSql.php
@@ -128,7 +128,7 @@ public static function sql(
$highlighter = new NullHighlighter();
}
- $var = (new SqlFormatter($highlighter))->format($sql);
+ $var = new SqlFormatter($highlighter)->format($sql);
$var = trim($var);
if ($showHtml) {
diff --git a/src/DebugTimer.php b/src/DebugTimer.php
index 7c9b32edc..d512d1b91 100644
--- a/src/DebugTimer.php
+++ b/src/DebugTimer.php
@@ -26,7 +26,7 @@ class DebugTimer
/**
* Internal timers array
*/
- protected static array $_timers = [];
+ protected static array $timers = [];
/**
* Start an benchmarking timer.
@@ -55,7 +55,7 @@ public static function start(?string $name = null, ?string $message = null): boo
$_name = $name;
$i = 1;
- while (isset(self::$_timers[$name])) {
+ while (isset(self::$timers[$name])) {
$i++;
$name = $_name . ' #' . $i;
}
@@ -64,7 +64,7 @@ public static function start(?string $name = null, ?string $message = null): boo
$message .= ' #' . $i;
}
- self::$_timers[$name] = [
+ self::$timers[$name] = [
'start' => $start,
'message' => $message,
'named' => $named,
@@ -85,30 +85,30 @@ public static function stop(?string $name = null): bool
{
$end = microtime(true);
if (!$name) {
- $names = array_reverse(array_keys(self::$_timers));
+ $names = array_reverse(array_keys(self::$timers));
foreach ($names as $name) {
- if (!empty(self::$_timers[$name]['end'])) {
+ if (!empty(self::$timers[$name]['end'])) {
continue;
}
- if (empty(self::$_timers[$name]['named'])) {
+ if (empty(self::$timers[$name]['named'])) {
break;
}
}
} else {
$i = 1;
$_name = $name;
- while (isset(self::$_timers[$name])) {
- if (empty(self::$_timers[$name]['end'])) {
+ while (isset(self::$timers[$name])) {
+ if (empty(self::$timers[$name]['end'])) {
break;
}
$i++;
$name = $_name . ' #' . $i;
}
}
- if (!isset(self::$_timers[$name])) {
+ if (!isset(self::$timers[$name])) {
return false;
}
- self::$_timers[$name]['end'] = $end;
+ self::$timers[$name]['end'] = $end;
return true;
}
@@ -126,8 +126,8 @@ public static function getAll(bool $clear = false): array
$now = microtime(true);
$times = [];
- if (!empty(self::$_timers)) {
- $firstTimer = reset(self::$_timers);
+ if (self::$timers !== []) {
+ $firstTimer = reset(self::$timers);
$_end = $firstTimer['start'];
} else {
$_end = $now;
@@ -139,10 +139,8 @@ public static function getAll(bool $clear = false): array
'time' => round($_end - $start, 6),
'named' => null,
];
- foreach (self::$_timers as $name => $timer) {
- if (!isset($timer['end'])) {
- $timer['end'] = $now;
- }
+ foreach (self::$timers as $name => $timer) {
+ $timer['end'] ??= $now;
$times[$name] = array_merge($timer, [
'start' => $timer['start'] - $start,
'end' => $timer['end'] - $start,
@@ -150,7 +148,7 @@ public static function getAll(bool $clear = false): array
]);
}
if ($clear) {
- self::$_timers = [];
+ self::$timers = [];
}
return $times;
@@ -163,7 +161,7 @@ public static function getAll(bool $clear = false): array
*/
public static function clear(): bool
{
- self::$_timers = [];
+ self::$timers = [];
return true;
}
@@ -177,11 +175,11 @@ public static function clear(): bool
*/
public static function elapsedTime(string $name = 'default', int $precision = 5): float
{
- if (!isset(self::$_timers[$name]['start']) || !isset(self::$_timers[$name]['end'])) {
+ if (!isset(self::$timers[$name]['start']) || !isset(self::$timers[$name]['end'])) {
return 0;
}
- return round(self::$_timers[$name]['end'] - self::$_timers[$name]['start'], $precision);
+ return round(self::$timers[$name]['end'] - self::$timers[$name]['start'], $precision);
}
/**
diff --git a/src/Log/Engine/DebugKitLog.php b/src/Log/Engine/DebugKitLog.php
index cc2e2a2fa..6e6b09232 100644
--- a/src/Log/Engine/DebugKitLog.php
+++ b/src/Log/Engine/DebugKitLog.php
@@ -25,7 +25,7 @@ class DebugKitLog extends BaseLog
/**
* logs
*/
- protected array $_logs = [];
+ protected array $logs = [];
/**
* Captures log messages in memory
@@ -37,10 +37,8 @@ class DebugKitLog extends BaseLog
*/
public function log(mixed $level, Stringable|string $message, array $context = []): void
{
- if (!isset($this->_logs[$level])) {
- $this->_logs[$level] = [];
- }
- $this->_logs[$level][] = [date('Y-m-d H:i:s'), $this->interpolate($message)];
+ $this->logs[$level] ??= [];
+ $this->logs[$level][] = [date('Y-m-d H:i:s'), $this->interpolate($message)];
}
/**
@@ -50,7 +48,7 @@ public function log(mixed $level, Stringable|string $message, array $context = [
*/
public function all(): array
{
- return $this->_logs;
+ return $this->logs;
}
/**
@@ -60,7 +58,7 @@ public function all(): array
*/
public function count(): int
{
- return array_reduce($this->_logs, function (int|float $sum, $v): int {
+ return array_reduce($this->logs, function (int $sum, $v): int {
return $sum + count($v);
}, 0);
}
@@ -72,6 +70,6 @@ public function count(): int
*/
public function noLogs(): bool
{
- return $this->_logs === [];
+ return $this->logs === [];
}
}
diff --git a/src/Model/Entity/Panel.php b/src/Model/Entity/Panel.php
index 49f3bf02d..b4ddcd6dc 100644
--- a/src/Model/Entity/Panel.php
+++ b/src/Model/Entity/Panel.php
@@ -33,7 +33,7 @@ class Panel extends Entity
*
* @var list
*/
- protected array $_hidden = ['content'];
+ protected array $hidden = ['content'];
/**
* Read the stream contents or inflate deflated data.
diff --git a/src/Model/Table/RequestsTable.php b/src/Model/Table/RequestsTable.php
index 6a716042d..c1d395d78 100644
--- a/src/Model/Table/RequestsTable.php
+++ b/src/Model/Table/RequestsTable.php
@@ -116,16 +116,15 @@ public function gc(): void
}
try {
- $noPurge = $this->find()
+ $noPurge = $this->unhydratedFind()
->select(['id'])
- ->enableHydration(false)
->orderBy(['requested_at' => 'desc'])
->limit(Configure::read('DebugKit.requestCount') ?: 20)
->all()
->extract('id')
->toArray();
- if (empty($noPurge)) {
+ if ($noPurge === []) {
return;
}
diff --git a/src/Panel/DeprecationsPanel.php b/src/Panel/DeprecationsPanel.php
index 65b037ff7..ed12bb8be 100644
--- a/src/Panel/DeprecationsPanel.php
+++ b/src/Panel/DeprecationsPanel.php
@@ -32,14 +32,14 @@ class DeprecationsPanel extends DebugPanel
/**
* instance of DebugInclude
*/
- protected DebugInclude $_debug;
+ protected DebugInclude $debug;
/**
* construct
*/
public function __construct()
{
- $this->_debug = new DebugInclude();
+ $this->debug = new DebugInclude();
}
/**
@@ -47,7 +47,7 @@ public function __construct()
*
* @return array
*/
- protected function _prepare(): array
+ protected function prepare(): array
{
$errors = static::$deprecatedErrors;
$return = ['cake' => [], 'app' => [], 'plugins' => [], 'vendor' => [], 'other' => []];
@@ -62,26 +62,26 @@ protected function _prepare(): array
'message' => $error['message'],
];
- $pluginName = $this->_debug->getPluginName($file);
+ $pluginName = $this->debug->getPluginName($file);
/** @var string|false $pluginName */
if ($pluginName) {
- $errorData['niceFile'] = $this->_debug->niceFileName($file, 'plugin', $pluginName);
+ $errorData['niceFile'] = $this->debug->niceFileName($file, 'plugin', $pluginName);
$return['plugins'][$pluginName][] = $errorData;
- } elseif ($this->_debug->isAppFile($file)) {
- $errorData['niceFile'] = $this->_debug->niceFileName($file, 'app');
+ } elseif ($this->debug->isAppFile($file)) {
+ $errorData['niceFile'] = $this->debug->niceFileName($file, 'app');
$return['app'][] = $errorData;
- } elseif ($this->_debug->isCakeFile($file)) {
- $errorData['niceFile'] = $this->_debug->niceFileName($file, 'cake');
+ } elseif ($this->debug->isCakeFile($file)) {
+ $errorData['niceFile'] = $this->debug->niceFileName($file, 'cake');
$return['cake'][] = $errorData;
} else {
/** @var string|false $vendorName */
- $vendorName = $this->_debug->getComposerPackageName($file);
+ $vendorName = $this->debug->getComposerPackageName($file);
if ($vendorName) {
- $errorData['niceFile'] = $this->_debug->niceFileName($file, 'vendor', $vendorName);
+ $errorData['niceFile'] = $this->debug->niceFileName($file, 'vendor', $vendorName);
$return['vendor'][$vendorName][] = $errorData;
} else {
- $errorData['niceFile'] = $this->_debug->niceFileName($file, 'root');
+ $errorData['niceFile'] = $this->debug->niceFileName($file, 'root');
$return['other'][] = $errorData;
}
}
@@ -121,9 +121,9 @@ public static function clearDeprecatedErrors(): void
*/
public function summary(): string
{
- $data = $this->_data;
- if (empty($data)) {
- $data = $this->_prepare();
+ $data = $this->data;
+ if ($data === []) {
+ $data = $this->prepare();
}
return (string)array_reduce($data, function ($carry, $item) {
@@ -152,6 +152,6 @@ public function summary(): string
*/
public function shutdown(EventInterface $event): void
{
- $this->_data = $this->_prepare();
+ $this->data = $this->prepare();
}
}
diff --git a/src/Panel/EnvironmentPanel.php b/src/Panel/EnvironmentPanel.php
index 3291fe80c..6d449a7a0 100644
--- a/src/Panel/EnvironmentPanel.php
+++ b/src/Panel/EnvironmentPanel.php
@@ -27,14 +27,14 @@ class EnvironmentPanel extends DebugPanel
/**
* instance of DebugInclude
*/
- protected DebugInclude $_debug;
+ protected DebugInclude $debug;
/**
* construct
*/
public function __construct()
{
- $this->_debug = new DebugInclude();
+ $this->debug = new DebugInclude();
}
/**
@@ -42,7 +42,7 @@ public function __construct()
*
* @return array
*/
- protected function _prepare(): array
+ protected function prepare(): array
{
$return = [];
// PHP Data
@@ -89,7 +89,7 @@ protected function _prepare(): array
$var = get_defined_constants(true);
$return['app'] = array_diff_key($var['user'], $return['cake'], $hiddenCakeConstants);
- $includePaths = $this->_debug->includePaths();
+ $includePaths = $this->debug->includePaths();
foreach ($includePaths as $k => $v) {
$includePaths[$k] = Debugger::exportVarAsNodes($v);
}
@@ -109,7 +109,7 @@ protected function _prepare(): array
*/
public function shutdown(EventInterface $event): void
{
- $this->_data = $this->_prepare();
+ $this->data = $this->prepare();
}
/**
@@ -123,31 +123,31 @@ protected function prepareIncludedFiles(): array
foreach (get_included_files() as $file) {
/** @var string|false $pluginName */
- $pluginName = $this->_debug->getPluginName($file);
+ $pluginName = $this->debug->getPluginName($file);
if ($pluginName) {
- $return['plugins'][$pluginName][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName(
+ $return['plugins'][$pluginName][$this->debug->getFileType($file)][] = $this->debug->niceFileName(
$file,
'plugin',
$pluginName,
);
- } elseif ($this->_debug->isAppFile($file)) {
- $return['app'][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName($file, 'app');
- } elseif ($this->_debug->isCakeFile($file)) {
- $return['cake'][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName($file, 'cake');
+ } elseif ($this->debug->isAppFile($file)) {
+ $return['app'][$this->debug->getFileType($file)][] = $this->debug->niceFileName($file, 'app');
+ } elseif ($this->debug->isCakeFile($file)) {
+ $return['cake'][$this->debug->getFileType($file)][] = $this->debug->niceFileName($file, 'cake');
} else {
/** @var string|false $vendorName */
- $vendorName = $this->_debug->getComposerPackageName($file);
+ $vendorName = $this->debug->getComposerPackageName($file);
if ($vendorName) {
- $return['vendor'][$vendorName][] = $this->_debug->niceFileName($file, 'vendor', $vendorName);
+ $return['vendor'][$vendorName][] = $this->debug->niceFileName($file, 'vendor', $vendorName);
} else {
- $return['other'][] = $this->_debug->niceFileName($file, 'root');
+ $return['other'][] = $this->debug->niceFileName($file, 'root');
}
}
}
- $return['paths'] = $this->_debug->includePaths();
+ $return['paths'] = $this->debug->includePaths();
ksort($return['app']);
ksort($return['cake']);
diff --git a/src/Panel/IncludePanel.php b/src/Panel/IncludePanel.php
index 640f76920..6bbae0b45 100644
--- a/src/Panel/IncludePanel.php
+++ b/src/Panel/IncludePanel.php
@@ -29,14 +29,14 @@ class IncludePanel extends DebugPanel
/**
* instance of DebugInclude
*/
- protected DebugInclude $_debug;
+ protected DebugInclude $debug;
/**
* construct
*/
public function __construct()
{
- $this->_debug = new DebugInclude();
+ $this->debug = new DebugInclude();
deprecationWarning(
'5.1.0',
'Include panel is deprecated. Remove it from your panel configuration, and use Environment Panel instead.',
@@ -48,37 +48,37 @@ public function __construct()
*
* @return array
*/
- protected function _prepare(): array
+ protected function prepare(): array
{
$return = ['cake' => [], 'app' => [], 'plugins' => [], 'vendor' => [], 'other' => []];
foreach (get_included_files() as $file) {
/** @var string|false $pluginName */
- $pluginName = $this->_debug->getPluginName($file);
+ $pluginName = $this->debug->getPluginName($file);
if ($pluginName) {
- $return['plugins'][$pluginName][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName(
+ $return['plugins'][$pluginName][$this->debug->getFileType($file)][] = $this->debug->niceFileName(
$file,
'plugin',
$pluginName,
);
- } elseif ($this->_debug->isAppFile($file)) {
- $return['app'][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName($file, 'app');
- } elseif ($this->_debug->isCakeFile($file)) {
- $return['cake'][$this->_debug->getFileType($file)][] = $this->_debug->niceFileName($file, 'cake');
+ } elseif ($this->debug->isAppFile($file)) {
+ $return['app'][$this->debug->getFileType($file)][] = $this->debug->niceFileName($file, 'app');
+ } elseif ($this->debug->isCakeFile($file)) {
+ $return['cake'][$this->debug->getFileType($file)][] = $this->debug->niceFileName($file, 'cake');
} else {
/** @var string|false $vendorName */
- $vendorName = $this->_debug->getComposerPackageName($file);
+ $vendorName = $this->debug->getComposerPackageName($file);
if ($vendorName) {
- $return['vendor'][$vendorName][] = $this->_debug->niceFileName($file, 'vendor', $vendorName);
+ $return['vendor'][$vendorName][] = $this->debug->niceFileName($file, 'vendor', $vendorName);
} else {
- $return['other'][] = $this->_debug->niceFileName($file, 'root');
+ $return['other'][] = $this->debug->niceFileName($file, 'root');
}
}
}
- $return['paths'] = $this->_debug->includePaths();
+ $return['paths'] = $this->debug->includePaths();
ksort($return['app']);
ksort($return['cake']);
@@ -103,9 +103,9 @@ protected function _prepare(): array
*/
public function summary(): string
{
- $data = $this->_data;
- if (empty($data)) {
- $data = $this->_prepare();
+ $data = $this->data;
+ if ($data === []) {
+ $data = $this->prepare();
}
unset($data['paths']);
@@ -124,6 +124,6 @@ public function summary(): string
*/
public function shutdown(EventInterface $event): void
{
- $this->_data = $this->_prepare();
+ $this->data = $this->prepare();
}
}
diff --git a/src/Panel/MailPanel.php b/src/Panel/MailPanel.php
index 2119b9ec2..d298dad0c 100644
--- a/src/Panel/MailPanel.php
+++ b/src/Panel/MailPanel.php
@@ -39,11 +39,11 @@ class MailPanel extends DebugPanel
public function initialize(): void
{
$reflection = new ReflectionClass(TransportFactory::class);
- $property = $reflection->getProperty('_config');
+ $property = $reflection->getProperty('config');
/** @var array<\Cake\Mailer\AbstractTransport|array> $configs */
$configs = $property->getValue();
-
- $log = $this->emailLog = new ArrayObject();
+ $log = new ArrayObject();
+ $this->emailLog = $log;
foreach ($configs as $name => $transport) {
if (is_object($transport)) {
@@ -64,7 +64,7 @@ public function initialize(): void
$configs[$name] = $transport;
}
- $reflection->setStaticPropertyValue('_config', $configs);
+ $reflection->setStaticPropertyValue('config', $configs);
}
/**
diff --git a/src/Panel/PackagesPanel.php b/src/Panel/PackagesPanel.php
index 81750a0b5..da53a7a8c 100644
--- a/src/Panel/PackagesPanel.php
+++ b/src/Panel/PackagesPanel.php
@@ -30,8 +30,8 @@ class PackagesPanel extends DebugPanel
*/
public function data(): array
{
- $packages = $devPackages = [];
-
+ $packages = [];
+ $devPackages = [];
$lockFile = new JsonFile(ROOT . DIRECTORY_SEPARATOR . 'composer.lock');
if ($lockFile->exists()) {
$lockContent = $lockFile->read();
diff --git a/src/Panel/PanelRegistry.php b/src/Panel/PanelRegistry.php
index b8163f7f9..717a45155 100644
--- a/src/Panel/PanelRegistry.php
+++ b/src/Panel/PanelRegistry.php
@@ -50,7 +50,7 @@ public function __construct(EventManager $eventManager)
* @param string $class Partial class name to resolve.
* @return string|null Either the correct class name, null if the class is not found.
*/
- protected function _resolveClassName(string $class): ?string
+ protected function resolveClassName(string $class): ?string
{
return App::className($class, 'Panel', 'Panel');
}
@@ -61,11 +61,11 @@ protected function _resolveClassName(string $class): ?string
* Part of the template method for Cake\Utility\ObjectRegistry::load()
*
* @param string $class The classname that is missing.
- * @param string $plugin The plugin the component is missing in.
+ * @param string|null $plugin The plugin the component is missing in.
* @return void
* @throws \RuntimeException
*/
- protected function _throwMissingClassError(string $class, ?string $plugin): void
+ protected function throwMissingClassError(string $class, ?string $plugin): void
{
throw new RuntimeException(sprintf("Unable to find '%s' panel.", $class));
}
@@ -80,7 +80,7 @@ protected function _throwMissingClassError(string $class, ?string $plugin): void
* @param array $config An array of config to use for the panel.
* @return \DebugKit\DebugPanel The constructed panel class.
*/
- protected function _create(object|string $class, string $alias, array $config): DebugPanel
+ protected function create(object|string $class, string $alias, array $config): DebugPanel
{
$instance = is_string($class) ? new $class() : $class;
diff --git a/src/Panel/PluginsPanel.php b/src/Panel/PluginsPanel.php
index b8011740e..9cd6c1351 100644
--- a/src/Panel/PluginsPanel.php
+++ b/src/Panel/PluginsPanel.php
@@ -31,7 +31,7 @@ public function initialize(): void
$loadedPluginsCollection = Plugin::getCollection();
$config = PluginConfig::getAppConfig();
- $this->_data['hasEmptyAppConfig'] = empty($config);
+ $this->data['hasEmptyAppConfig'] = $config === [];
$plugins = [];
foreach ($config as $pluginName => $options) {
@@ -43,7 +43,7 @@ public function initialize(): void
];
}
- $this->_data['plugins'] = $plugins;
+ $this->data['plugins'] = $plugins;
}
/**
@@ -53,10 +53,10 @@ public function initialize(): void
*/
public function summary(): string
{
- if (!isset($this->_data['plugins'])) {
+ if (!isset($this->data['plugins'])) {
return '0';
}
- return (string)count($this->_data['plugins']);
+ return (string)count($this->data['plugins']);
}
}
diff --git a/src/Panel/RequestPanel.php b/src/Panel/RequestPanel.php
index 08f9bf491..b0c3d1556 100644
--- a/src/Panel/RequestPanel.php
+++ b/src/Panel/RequestPanel.php
@@ -48,7 +48,7 @@ public function shutdown(EventInterface $event): void
$attributes[$attr] = Debugger::exportVarAsNodes($value, $maxDepth);
}
- $this->_data = [
+ $this->data = [
'params' => $request->getAttribute('params'),
'attributes' => $attributes,
'query' => Debugger::exportVarAsNodes($request->getQueryParams(), $maxDepth),
diff --git a/src/Panel/RoutesPanel.php b/src/Panel/RoutesPanel.php
index 01c9aa5b6..8620f16b3 100644
--- a/src/Panel/RoutesPanel.php
+++ b/src/Panel/RoutesPanel.php
@@ -47,7 +47,7 @@ public function summary(): string
public function shutdown(EventInterface $event): void
{
$controller = $event->getSubject();
- $this->_data = [
+ $this->data = [
'matchedRoute' => $controller->getRequest()->getParam('_matchedRoute'),
];
}
diff --git a/src/Panel/SessionPanel.php b/src/Panel/SessionPanel.php
index 84b73ffb7..3de9947d1 100644
--- a/src/Panel/SessionPanel.php
+++ b/src/Panel/SessionPanel.php
@@ -43,6 +43,6 @@ public function shutdown(EventInterface $event): void
$maxDepth = Configure::read('DebugKit.maxDepth', 5);
$content = Debugger::exportVarAsNodes($request->getSession()->read(), $maxDepth);
- $this->_data = compact('content');
+ $this->data = compact('content');
}
}
diff --git a/src/Panel/SqlLogPanel.php b/src/Panel/SqlLogPanel.php
index 12b8657b8..b1d6ac2e8 100644
--- a/src/Panel/SqlLogPanel.php
+++ b/src/Panel/SqlLogPanel.php
@@ -32,7 +32,7 @@ class SqlLogPanel extends DebugPanel
/**
* Loggers connected
*/
- protected static array $_loggers = [];
+ protected static array $loggers = [];
/**
* Initialize hook - configures logger.
@@ -81,7 +81,7 @@ public static function addConnection(string $name): void
if ($logger instanceof DebugLog) {
$logger->setIncludeSchema($includeSchemaReflection);
- static::$_loggers[] = $logger;
+ static::$loggers[] = $logger;
return;
}
@@ -90,7 +90,7 @@ public static function addConnection(string $name): void
/** @var \Cake\Database\Driver $driver */
$driver->setLogger($logger);
- static::$_loggers[] = $logger;
+ static::$loggers[] = $logger;
}
/**
@@ -104,7 +104,7 @@ public function data(): array
'tables' => array_map(function (Table $table): string {
return $table->getAlias();
}, $this->getTableLocator()->genericInstances()),
- 'loggers' => static::$_loggers,
+ 'loggers' => static::$loggers,
];
}
@@ -115,8 +115,9 @@ public function data(): array
*/
public function summary(): string
{
- $count = $time = 0;
- foreach (static::$_loggers as $logger) {
+ $count = 0;
+ $time = 0;
+ foreach (static::$loggers as $logger) {
$count += count($logger->queries());
$time += $logger->totalTime();
}
diff --git a/src/Panel/VariablesPanel.php b/src/Panel/VariablesPanel.php
index b84a32b45..931590d5f 100644
--- a/src/Panel/VariablesPanel.php
+++ b/src/Panel/VariablesPanel.php
@@ -62,7 +62,7 @@ protected function _getErrors(EntityInterface $entity): array
* @param object $item The item whose debug info to retrieve.
* @return array|string
*/
- protected function _walkDebugInfo(callable $walker, object $item): array|string
+ protected function walkDebugInfo(callable $walker, object $item): array|string
{
try {
/** @phpstan-ignore method.notFound */
@@ -101,14 +101,14 @@ public function shutdown(EventInterface $event): void
$errors[$k] = Debugger::exportVarAsNodes($this->_getErrors($v), $varsMaxDepth);
} elseif ($v instanceof Form) {
$formErrors = $v->getErrors();
- if ($formErrors) {
+ if ($formErrors !== []) {
$errors[$k] = Debugger::exportVarAsNodes($formErrors, $varsMaxDepth);
}
}
$content[$k] = Debugger::exportVarAsNodes($v, $varsMaxDepth);
}
- $this->_data = [
+ $this->data = [
'variables' => $content,
'errors' => $errors,
'varsMaxDepth' => $varsMaxDepth,
@@ -122,10 +122,10 @@ public function shutdown(EventInterface $event): void
*/
public function summary(): string
{
- if (!isset($this->_data['variables'])) {
+ if (!isset($this->data['variables'])) {
return '0';
}
- return (string)count($this->_data['variables']);
+ return (string)count($this->data['variables']);
}
}
diff --git a/src/ToolbarService.php b/src/ToolbarService.php
index cd14a3412..d8cb30982 100644
--- a/src/ToolbarService.php
+++ b/src/ToolbarService.php
@@ -48,7 +48,7 @@ class ToolbarService
/**
* Default configuration.
*/
- protected array $_defaultConfig = [
+ protected array $defaultConfig = [
'panels' => [
'DebugKit.Cache' => true,
'DebugKit.Request' => true,
@@ -98,9 +98,7 @@ public function registry(): PanelRegistry
*/
public function isEnabled(): bool
{
- if (!isset($GLOBALS['FORCE_DEBUGKIT_TOOLBAR'])) {
- $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] = false;
- }
+ $GLOBALS['FORCE_DEBUGKIT_TOOLBAR'] ??= false;
if (
defined('PHPUNIT_COMPOSER_INSTALL') &&
!$GLOBALS['FORCE_DEBUGKIT_TOOLBAR']
diff --git a/src/View/Helper/SimpleGraphHelper.php b/src/View/Helper/SimpleGraphHelper.php
index 9184f25df..3b7d82f11 100644
--- a/src/View/Helper/SimpleGraphHelper.php
+++ b/src/View/Helper/SimpleGraphHelper.php
@@ -36,7 +36,7 @@ class SimpleGraphHelper extends Helper
* - valueType => string (value, percentage)
* - style => array
*/
- protected array $_defaultSettings = [
+ protected array $defaultSettings = [
'max' => 100,
'width' => 350,
'valueType' => 'value',
@@ -52,7 +52,7 @@ class SimpleGraphHelper extends Helper
*/
public function bar(float|int $value, float|int $offset, array $options = []): string
{
- $settings = array_merge($this->_defaultSettings, $options);
+ $settings = array_merge($this->defaultSettings, $options);
$max = $settings['max'];
$width = $settings['width'];
$valueType = $settings['valueType'];
diff --git a/tests/TestCase/Controller/ComposerControllerTest.php b/tests/TestCase/Controller/ComposerControllerTest.php
index 4a56aa4ce..08b9fb815 100644
--- a/tests/TestCase/Controller/ComposerControllerTest.php
+++ b/tests/TestCase/Controller/ComposerControllerTest.php
@@ -52,7 +52,7 @@ public function testCheckDependencies(): void
$this->post('/debug-kit/composer/check-dependencies');
$this->assertResponseOk();
$this->assertContentType('application/json');
- $data = json_decode((string)$this->_response->getBody(), true);
+ $data = json_decode((string)$this->response->getBody(), true);
$this->assertArrayHasKey('packages', $data);
}
}
diff --git a/tests/TestCase/Controller/DebugKitControllerTest.php b/tests/TestCase/Controller/DebugKitControllerTest.php
index ed2cdefc8..7576fe63e 100644
--- a/tests/TestCase/Controller/DebugKitControllerTest.php
+++ b/tests/TestCase/Controller/DebugKitControllerTest.php
@@ -24,12 +24,10 @@
use Cake\TestSuite\TestCase;
use DebugKit\Controller\DebugKitController;
use DebugKit\TestApp\Application;
-use PHPUnit\Framework\Attributes\UsesClass;
/**
* DebugKit controller test.
*/
-#[UsesClass('\DebugKit\Controller\DebugKitController')]
class DebugKitControllerTest extends TestCase
{
use IntegrationTestTrait;
@@ -54,9 +52,9 @@ public function testDebugDisabled(): void
* Build controller with AuthorizationService
* in request attribute
*
- * @return DebugKit\Controller\DebugKitController
+ * @return \DebugKit\Controller\DebugKitController
*/
- private function _buildController(): DebugKitController
+ private function buildController(): DebugKitController
{
$request = new ServerRequest(['url' => '/debug-kit/']);
@@ -76,7 +74,9 @@ private function _buildController(): DebugKitController
*/
public function testAuthorizationSkipped(): void
{
- $controller = $this->_buildController();
+ $this->markTestSkipped('Skipped until the authorization plugin is added back as dev dependency');
+
+ $controller = $this->buildController();
$event = new Event('testing');
$controller->beforeFilter($event);
diff --git a/tests/TestCase/Controller/MailPreviewControllerTest.php b/tests/TestCase/Controller/MailPreviewControllerTest.php
index 13c5bfce7..61feedc3c 100644
--- a/tests/TestCase/Controller/MailPreviewControllerTest.php
+++ b/tests/TestCase/Controller/MailPreviewControllerTest.php
@@ -45,7 +45,7 @@ public function testEmailPluginPassedToView(): void
*
* @return void
*/
- public function testEmailRejectInvalidClassName()
+ public function testEmailRejectInvalidClassName(): void
{
$this->get('/debug-kit/mail-preview/preview/Cake\Utility\Inflector/slug');
$this->assertResponseCode(404);
diff --git a/tests/TestCase/Controller/PanelsControllerTest.php b/tests/TestCase/Controller/PanelsControllerTest.php
index 0ea2dd15d..f0fea03d7 100644
--- a/tests/TestCase/Controller/PanelsControllerTest.php
+++ b/tests/TestCase/Controller/PanelsControllerTest.php
@@ -105,7 +105,7 @@ public function testViewNotExists(): void
*
* @return void
*/
- public function testViewDeprecationsPanelEmpty()
+ public function testViewDeprecationsPanelEmpty(): void
{
$request = $this->makeRequest();
$panel = $this->makePanel(
@@ -125,7 +125,7 @@ public function testViewDeprecationsPanelEmpty()
/**
* @return void
*/
- public function testViewDeprecationsPanelWithEntries()
+ public function testViewDeprecationsPanelWithEntries(): void
{
$request = $this->makeRequest();
$entry = ['niceFile' => 'src/Foo.php', 'line' => 1, 'message' => 'deprecated thing'];
@@ -151,7 +151,7 @@ public function testViewDeprecationsPanelWithEntries()
*
* @return void
*/
- public function testViewDeprecationsPanelOtherOnly()
+ public function testViewDeprecationsPanelOtherOnly(): void
{
$request = $this->makeRequest();
$entry = ['niceFile' => 'src/Bar.php', 'line' => 2, 'message' => 'only-other deprecation'];
@@ -178,7 +178,7 @@ public function testViewDeprecationsPanelOtherOnly()
*
* @return void
*/
- public function testViewVariablesPanelErrorIsEscaped()
+ public function testViewVariablesPanelErrorIsEscaped(): void
{
$request = $this->makeRequest();
$panel = $this->makePanel(
diff --git a/tests/TestCase/Controller/ToolbarControllerTest.php b/tests/TestCase/Controller/ToolbarControllerTest.php
index b2dab3613..418cf988b 100644
--- a/tests/TestCase/Controller/ToolbarControllerTest.php
+++ b/tests/TestCase/Controller/ToolbarControllerTest.php
@@ -77,7 +77,7 @@ public function testClearCache(): void
*
* @return void
*/
- public function testClearCacheUnknownEngine()
+ public function testClearCacheUnknownEngine(): void
{
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
$this->post('/debug-kit/toolbar/clear-cache', ['name' => 'does-not-exist']);
@@ -89,7 +89,7 @@ public function testClearCacheUnknownEngine()
*
* @return void
*/
- public function testClearSession()
+ public function testClearSession(): void
{
$this->session(['test' => 'value']);
$this->configRequest(['headers' => ['Accept' => 'application/json']]);
diff --git a/tests/TestCase/DebugKitPluginTest.php b/tests/TestCase/DebugKitPluginTest.php
index 5d48d8656..a7906d817 100644
--- a/tests/TestCase/DebugKitPluginTest.php
+++ b/tests/TestCase/DebugKitPluginTest.php
@@ -88,7 +88,7 @@ public function testSetDeprecationHandler(): void
*/
public function testMiddlewareNotLoadedInTests(): void
{
- $baseApp = new Application(dirname(__DIR__) . '/config');
+ $baseApp = new Application(__DIR__ . '/../config');
$baseApp->pluginBootstrap();
$middlewareQueue = $baseApp->middleware(new MiddlewareQueue());
$beforeCount = $middlewareQueue->count();
diff --git a/tests/TestCase/FixtureFactoryTrait.php b/tests/TestCase/FixtureFactoryTrait.php
index 869c93637..5bf7a8789 100644
--- a/tests/TestCase/FixtureFactoryTrait.php
+++ b/tests/TestCase/FixtureFactoryTrait.php
@@ -32,34 +32,32 @@ protected function makeRequest()
protected function makePanel($request, $name = 'DebugKit.Request', $title = 'Request', $element = 'DebugKit.request_panel', $content = null)
{
- if ($content === null) {
- $content = [
- 'attributes' => [
- Debugger::exportVarAsNodes([
- 'params' => [
- 'plugin' => null,
- 'controller' => 'Tasks',
- 'action' => 'add',
- '_ext' => null,
- 'pass' => [],
- ],
- ]),
- ],
- 'query' => Debugger::exportVarAsNodes([]),
- 'data' => Debugger::exportVarAsNodes([]),
- 'get' => Debugger::exportVarAsNodes([]),
- 'cookie' => Debugger::exportVarAsNodes([
- 'toolbarDisplay' => 'show',
+ $content ??= [
+ 'attributes' => [
+ Debugger::exportVarAsNodes([
+ 'params' => [
+ 'plugin' => null,
+ 'controller' => 'Tasks',
+ 'action' => 'add',
+ '_ext' => null,
+ 'pass' => [],
+ ],
]),
- 'params' => [
- 'plugin' => null,
- 'controller' => 'Tasks',
- 'action' => 'add',
- '_ext' => null,
- 'pass' => [],
- ],
- ];
- }
+ ],
+ 'query' => Debugger::exportVarAsNodes([]),
+ 'data' => Debugger::exportVarAsNodes([]),
+ 'get' => Debugger::exportVarAsNodes([]),
+ 'cookie' => Debugger::exportVarAsNodes([
+ 'toolbarDisplay' => 'show',
+ ]),
+ 'params' => [
+ 'plugin' => null,
+ 'controller' => 'Tasks',
+ 'action' => 'add',
+ '_ext' => null,
+ 'pass' => [],
+ ],
+ ];
$panels = $this->getTableLocator()->get('DebugKit.Panels');
$panel = $panels->newEntity([
'request_id' => $request->id,
diff --git a/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php b/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php
index 03f754622..1df6e928f 100644
--- a/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php
+++ b/tests/TestCase/Mailer/Transport/DebugKitTransportTest.php
@@ -68,7 +68,7 @@ public function testMethodProxy(): void
$this->assertSame('bloop', $this->transport->customMethod());
}
- public function testConstructorRejectsMissingDebugKitLog()
+ public function testConstructorRejectsMissingDebugKitLog(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('debugKitLog');
@@ -76,14 +76,14 @@ public function testConstructorRejectsMissingDebugKitLog()
new DebugKitTransport([]);
}
- public function testConstructorRejectsWrongDebugKitLogType()
+ public function testConstructorRejectsWrongDebugKitLogType(): void
{
$this->expectException(InvalidArgumentException::class);
new DebugKitTransport(['debugKitLog' => 'not-an-arrayobject']);
}
- public function testEmailCapture()
+ public function testEmailCapture(): void
{
$message = new Message();
$message->setSubject('Testing 123')
diff --git a/tests/TestCase/ToolbarServiceTest.php b/tests/TestCase/ToolbarServiceTest.php
index 59c78ff57..cf94b643d 100644
--- a/tests/TestCase/ToolbarServiceTest.php
+++ b/tests/TestCase/ToolbarServiceTest.php
@@ -564,7 +564,7 @@ public function testSaveDataSerializationError(): void
*
* @return void
*/
- public function testSaveDataPanelDataThrows()
+ public function testSaveDataPanelDataThrows(): void
{
$request = new Request([
'url' => '/articles',
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 9a2e5b2b0..40d58ae54 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -22,7 +22,7 @@
use DebugKit\DebugKitPlugin;
use function Cake\Core\env;
-require_once dirname(__DIR__) . '/vendor/autoload.php';
+require_once __DIR__ . '/../vendor/autoload.php';
// Path constants to a few helpful things.
if (!defined('DS')) {
diff --git a/tests/schema.php b/tests/schema.php
index 63e32a533..ef210bb7c 100644
--- a/tests/schema.php
+++ b/tests/schema.php
@@ -1,7 +1,7 @@
addField('accept', 'boolean');
}
@@ -48,7 +48,7 @@ public function validationDefault(Validator $validator): Validator
* @param array $data Form data.
* @return bool
*/
- protected function _execute(array $data): bool
+ protected function process(array $data): bool
{
return true;
}
diff --git a/tests/test_app/Panel/SimplePanel.php b/tests/test_app/Panel/SimplePanel.php
index 692397f3c..78bd34ca3 100644
--- a/tests/test_app/Panel/SimplePanel.php
+++ b/tests/test_app/Panel/SimplePanel.php
@@ -24,6 +24,6 @@ class SimplePanel extends DebugPanel
{
public function setData(array $data): void
{
- $this->_data = $data;
+ $this->data = $data;
}
}
diff --git a/tests/test_app/Stub/SimpleConnectionStub.php b/tests/test_app/Stub/SimpleConnectionStub.php
index 0f3a6948c..3cce98c8b 100644
--- a/tests/test_app/Stub/SimpleConnectionStub.php
+++ b/tests/test_app/Stub/SimpleConnectionStub.php
@@ -15,7 +15,7 @@ public function getDriver(string $role = self::ROLE_WRITE): object
return new stdClass();
}
- public function setCacher(CacheInterface $cacher)
+ public function setCacher(CacheInterface $cacher): static
{
return $this;
}