Skip to content

Commit 758ff33

Browse files
committed
Upgrade for CakePHP 6
1 parent 0412329 commit 758ff33

29 files changed

Lines changed: 122 additions & 135 deletions

‎.github/workflows/ci.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ permissions:
1616

1717
jobs:
1818
testsuite:
19-
uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@5.x
19+
uses: cakephp/.github/.github/workflows/testsuite-with-db.yml@6.x
2020
secrets: inherit
2121

2222
cs-stan:
23-
uses: cakephp/.github/.github/workflows/cs-stan.yml@5.x
23+
uses: cakephp/.github/.github/workflows/cs-stan.yml@6.x
2424
secrets: inherit

‎composer.json‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,14 @@
2828
"source": "https://github.com/cakephp/debug_kit"
2929
},
3030
"require": {
31-
"php": ">=8.1",
32-
"cakephp/cakephp": "^5.1",
31+
"php": ">=8.4",
32+
"cakephp/cakephp": "^6.0",
3333
"composer/composer": "^2.7.7",
3434
"doctrine/sql-formatter": "^1.1.3"
3535
},
3636
"require-dev": {
37-
"cakephp/authorization": "^3.0",
38-
"cakephp/cakephp-codesniffer": "^5.0",
39-
"phpunit/phpunit": "^10.5.32 || ^11.1.3 || ^12.0.9"
37+
"cakephp/cakephp-codesniffer": "^6.0",
38+
"phpunit/phpunit": "^12.0.9 || ^13.0"
4039
},
4140
"suggest": {
4241
"ext-pdo_sqlite": "DebugKit needs to store panel data in a database. SQLite is simple and easy to use."
@@ -75,6 +74,6 @@
7574
"rector-fix": "vendor/bin/rector process",
7675
"test": "phpunit"
7776
},
78-
"minimum-stability": "stable",
77+
"minimum-stability": "dev",
7978
"prefer-stable": true
8079
}

‎config/bootstrap.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* data in a browser-friendly way.
5151
* @return \Cake\Database\Query
5252
*/
53-
function sql(Query $query, $showValues = true, $showHtml = null)
53+
function sql(Query $query, bool $showValues = true, ?bool $showHtml = null): Query
5454
{
5555
return DebugSql::sql($query, $showValues, $showHtml, 1);
5656
}
@@ -69,7 +69,7 @@ function sql(Query $query, $showValues = true, $showHtml = null)
6969
* data in a browser-friendly way.
7070
* @return void
7171
*/
72-
function sqld(Query $query, $showValues = true, $showHtml = null)
72+
function sqld(Query $query, bool $showValues = true, ?bool $showHtml = null): void
7373
{
7474
DebugSql::sqld($query, $showValues, $showHtml, 2);
7575
}

‎config/routes.php‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,53 @@
44
use Cake\Routing\RouteBuilder;
55

66
return function (RouteBuilder $routes): void {
7-
$routes->plugin('DebugKit', ['path' => '/debug-kit'], function (RouteBuilder $routes): void {
7+
$routes->plugin('DebugKit', callback: function (RouteBuilder $routes): void {
88
$routes->setExtensions('json');
99
$routes->setRouteClass(DashedRoute::class);
1010

1111
$routes->connect(
1212
'/toolbar/clear-cache',
13-
['controller' => 'Toolbar', 'action' => 'clearCache']
13+
['controller' => 'Toolbar', 'action' => 'clearCache'],
1414
);
1515
$routes->connect(
1616
'/toolbar/clear-session',
17-
['controller' => 'Toolbar', 'action' => 'clearSession']
17+
['controller' => 'Toolbar', 'action' => 'clearSession'],
1818
);
1919
$routes->connect(
2020
'/toolbar/*',
21-
['controller' => 'Requests', 'action' => 'view']
21+
['controller' => 'Requests', 'action' => 'view'],
2222
);
2323
$routes->connect(
2424
'/panels/view/latest-history',
25-
['controller' => 'Panels', 'action' => 'latestHistory']
25+
['controller' => 'Panels', 'action' => 'latestHistory'],
2626
);
2727
$routes->connect(
2828
'/panels/view/*',
29-
['controller' => 'Panels', 'action' => 'view']
29+
['controller' => 'Panels', 'action' => 'view'],
3030
);
3131
$routes->connect(
3232
'/panels/*',
33-
['controller' => 'Panels', 'action' => 'index']
33+
['controller' => 'Panels', 'action' => 'index'],
3434
);
3535

3636
$routes->connect(
3737
'/composer/check-dependencies',
38-
['controller' => 'Composer', 'action' => 'checkDependencies']
38+
['controller' => 'Composer', 'action' => 'checkDependencies'],
3939
);
4040

4141
$routes->scope(
4242
'/mail-preview',
43-
['controller' => 'MailPreview'],
44-
function (RouteBuilder $routes): void {
43+
callback: function (RouteBuilder $routes): void {
4544
$routes->connect('/', ['action' => 'index']);
4645
$routes->connect('/preview', ['action' => 'email']);
4746
$routes->connect('/preview/*', ['action' => 'email']);
4847
$routes->connect('/sent/{panel}/{id}', ['action' => 'sent'], ['pass' => ['panel', 'id']]);
49-
}
48+
},
49+
params: ['controller' => 'MailPreview'],
5050
);
5151

5252
$routes->get('/', ['controller' => 'Dashboard', 'action' => 'index']);
5353
$routes->get('/dashboard', ['controller' => 'Dashboard', 'action' => 'index']);
5454
$routes->post('/dashboard/reset', ['controller' => 'Dashboard', 'action' => 'reset']);
55-
});
55+
}, params: ['path' => '/debug-kit']);
5656
};

‎phpcs.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0"?>
22
<ruleset name="CakePHP DebugKit">
3+
<file>config/</file>
34
<file>src/</file>
45
<file>tests/</file>
56

‎src/Cache/Engine/DebugEngine.php‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DebugEngine extends CacheEngine
2929
/**
3030
* Proxied engine
3131
*/
32-
protected CacheEngine $_engine;
32+
protected CacheEngine $engine;
3333

3434
protected LoggerInterface $logger;
3535

@@ -57,9 +57,9 @@ class DebugEngine extends CacheEngine
5757
public function __construct(CacheEngine|array $config, string $name, LoggerInterface $logger)
5858
{
5959
if ($config instanceof CacheEngine) {
60-
$this->_engine = $config;
60+
$this->engine = $config;
6161
} else {
62-
$this->_config = $config;
62+
$this->config = $config;
6363
}
6464

6565
$this->logger = $logger;
@@ -74,9 +74,9 @@ public function __construct(CacheEngine|array $config, string $name, LoggerInter
7474
*/
7575
public function init(array $config = []): bool
7676
{
77-
if (!isset($this->_engine)) {
77+
if (!isset($this->engine)) {
7878
$registry = new CacheRegistry();
79-
$this->_engine = $registry->load('spies', $this->_config);
79+
$this->engine = $registry->load('spies', $this->config);
8080
unset($registry);
8181
}
8282

@@ -90,7 +90,7 @@ public function init(array $config = []): bool
9090
*/
9191
public function engine(): CacheEngine
9292
{
93-
return $this->_engine;
93+
return $this->engine;
9494
}
9595

9696
/**
@@ -135,7 +135,7 @@ protected function log(string $operation, float $duration, ?string $key = null):
135135
public function set($key, $value, $ttl = null): bool
136136
{
137137
$start = microtime(true);
138-
$result = $this->_engine->set($key, $value, $ttl);
138+
$result = $this->engine->set($key, $value, $ttl);
139139
$duration = microtime(true) - $start;
140140

141141
$this->track('set');
@@ -150,7 +150,7 @@ public function set($key, $value, $ttl = null): bool
150150
public function setMultiple($values, $ttl = null): bool
151151
{
152152
$start = microtime(true);
153-
$result = $this->_engine->setMultiple($values);
153+
$result = $this->engine->setMultiple($values);
154154
$duration = microtime(true) - $start;
155155

156156
$this->track('set');
@@ -165,7 +165,7 @@ public function setMultiple($values, $ttl = null): bool
165165
public function get(string $key, mixed $default = null): mixed
166166
{
167167
$start = microtime(true);
168-
$result = $this->_engine->get($key, $default);
168+
$result = $this->engine->get($key, $default);
169169
$duration = microtime(true) - $start;
170170
$metric = 'hit';
171171
if ($result === null) {
@@ -184,7 +184,7 @@ public function get(string $key, mixed $default = null): mixed
184184
public function getMultiple($keys, $default = null): iterable
185185
{
186186
$start = microtime(true);
187-
$result = $this->_engine->getMultiple($keys, $default);
187+
$result = $this->engine->getMultiple($keys, $default);
188188
$duration = microtime(true) - $start;
189189

190190
$this->track('get hit');
@@ -199,7 +199,7 @@ public function getMultiple($keys, $default = null): iterable
199199
public function increment(string $key, int $offset = 1): int|false
200200
{
201201
$start = microtime(true);
202-
$result = $this->_engine->increment($key, $offset);
202+
$result = $this->engine->increment($key, $offset);
203203
$duration = microtime(true) - $start;
204204

205205
$this->track('set');
@@ -214,7 +214,7 @@ public function increment(string $key, int $offset = 1): int|false
214214
public function decrement(string $key, int $offset = 1): int|false
215215
{
216216
$start = microtime(true);
217-
$result = $this->_engine->decrement($key, $offset);
217+
$result = $this->engine->decrement($key, $offset);
218218
$duration = microtime(true) - $start;
219219

220220
$this->track('set');
@@ -229,7 +229,7 @@ public function decrement(string $key, int $offset = 1): int|false
229229
public function delete($key): bool
230230
{
231231
$start = microtime(true);
232-
$result = $this->_engine->delete($key);
232+
$result = $this->engine->delete($key);
233233
$duration = microtime(true) - $start;
234234

235235
$this->track('delete');
@@ -244,7 +244,7 @@ public function delete($key): bool
244244
public function deleteMultiple($keys): bool
245245
{
246246
$start = microtime(true);
247-
$result = $this->_engine->deleteMultiple($keys);
247+
$result = $this->engine->deleteMultiple($keys);
248248
$duration = microtime(true) - $start;
249249

250250
$this->track('delete');
@@ -259,7 +259,7 @@ public function deleteMultiple($keys): bool
259259
public function clear(): bool
260260
{
261261
$start = microtime(true);
262-
$result = $this->_engine->clear();
262+
$result = $this->engine->clear();
263263
$duration = microtime(true) - $start;
264264

265265
$this->track('delete');
@@ -273,7 +273,7 @@ public function clear(): bool
273273
*/
274274
public function groups(): array
275275
{
276-
return $this->_engine->groups();
276+
return $this->engine->groups();
277277
}
278278

279279
/**
@@ -285,7 +285,7 @@ public function groups(): array
285285
*/
286286
public function getConfig(?string $key = null, mixed $default = null): mixed
287287
{
288-
return $this->_engine->getConfig($key, $default);
288+
return $this->engine->getConfig($key, $default);
289289
}
290290

291291
/**
@@ -297,9 +297,9 @@ public function getConfig(?string $key = null, mixed $default = null): mixed
297297
* @return $this
298298
* @throws \Cake\Core\Exception\CakeException When trying to set a key that is invalid.
299299
*/
300-
public function setConfig(array|string $key, mixed $value = null, bool $merge = true)
300+
public function setConfig(array|string $key, mixed $value = null, bool $merge = true): static
301301
{
302-
$this->_engine->setConfig($key, $value, $merge);
302+
$this->engine->setConfig($key, $value, $merge);
303303

304304
return $this;
305305
}
@@ -310,7 +310,7 @@ public function setConfig(array|string $key, mixed $value = null, bool $merge =
310310
public function clearGroup(string $group): bool
311311
{
312312
$start = microtime(true);
313-
$result = $this->_engine->clearGroup($group);
313+
$result = $this->engine->clearGroup($group);
314314
$duration = microtime(true) - $start;
315315

316316
$this->track('delete');
@@ -326,13 +326,13 @@ public function clearGroup(string $group): bool
326326
*/
327327
public function __toString(): string
328328
{
329-
if (isset($this->_engine)) {
329+
if (isset($this->engine)) {
330330
// phpcs:ignore SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
331-
[$ns, $class] = namespaceSplit($this->_engine::class);
331+
[$ns, $class] = namespaceSplit($this->engine::class);
332332

333333
return str_replace('Engine', '', $class);
334334
}
335335

336-
return $this->_config['className'];
336+
return $this->config['className'];
337337
}
338338
}

0 commit comments

Comments
 (0)