Skip to content

Commit cd05c7b

Browse files
committed
Merge branch '4.x' into 4.next
2 parents fb0bc84 + 83a747a commit cd05c7b

26 files changed

+136
-72
lines changed

Diff for: .editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ indent_size = 4
1111
insert_final_newline = true
1212
trim_trailing_whitespace = true
1313

14+
[*.neon]
15+
indent_style = tab
16+
1417
[*.js]
1518
indent_size = 2

Diff for: .github/dependabot.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ updates:
33
- package-ecosystem: composer
44
directory: "/"
55
schedule:
6-
interval: daily
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: github-actions
9+
directory: "/"
10+
schedule:
11+
interval: weekly
712
open-pull-requests-limit: 10
8-
ignore:
9-
- dependency-name: phpunit/phpunit
10-
versions:
11-
- "> 6.0"

Diff for: .github/workflows/ci.yml

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: CI
22

3-
43
on:
54
push:
65
branches:
@@ -9,9 +8,12 @@ on:
98
branches:
109
- '*'
1110

11+
permissions:
12+
contents: read
13+
1214
jobs:
1315
testsuite-linux:
14-
runs-on: ubuntu-18.04
16+
runs-on: ubuntu-20.04
1517
strategy:
1618
fail-fast: false
1719
matrix:
@@ -34,7 +36,7 @@ jobs:
3436
POSTGRES_PASSWORD: postgres
3537

3638
steps:
37-
- uses: actions/checkout@v2
39+
- uses: actions/checkout@v3
3840

3941
- name: Setup Service
4042
if: matrix.db-type == 'mysql'
@@ -58,7 +60,7 @@ jobs:
5860
run: echo "::set-output name=date::$(date +'%Y-%m')"
5961

6062
- name: Cache composer dependencies
61-
uses: actions/cache@v1
63+
uses: actions/cache@v3
6264
with:
6365
path: ${{ steps.composer-cache.outputs.dir }}
6466
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
@@ -92,28 +94,32 @@ jobs:
9294
9395
- name: Code Coverage Report
9496
if: success() && matrix.php-version == '7.4' && matrix.db-type == 'mysql'
95-
uses: codecov/codecov-action@v1
97+
uses: codecov/codecov-action@v3
9698

9799
cs-stan:
98100
name: Coding Standard & Static Analysis
99-
runs-on: ubuntu-18.04
101+
runs-on: ubuntu-20.04
100102

101103
steps:
102-
- uses: actions/checkout@v2
104+
- uses: actions/checkout@v3
103105

104106
- name: Setup PHP
105107
uses: shivammathur/setup-php@v2
106108
with:
107109
php-version: '7.4'
108110
extensions: mbstring, intl
109111
coverage: none
110-
tools: psalm:~4.10.0, cs2pr
112+
tools: cs2pr
111113

112114
- name: Composer Install
113-
run: composer install
115+
run: composer stan-setup
114116

115117
- name: Run phpcs
116118
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr
117119

118120
- name: Run psalm
119-
run: psalm --output-format=github
121+
run: vendor/bin/psalm.phar --output-format=github
122+
123+
- name: Run phpstan
124+
if: always()
125+
run: vendor/bin/phpstan.phar analyse --error-format=github

Diff for: .github/workflows/deploy_docs_4x.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Cloning repo
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1515
with:
1616
fetch-depth: 0
1717

Diff for: composer.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"source": "https://github.com/cakephp/debug_kit"
2424
},
2525
"require": {
26-
"php": ">=7.2",
26+
"php": ">=7.4",
2727
"cakephp/cakephp": "^4.4.0",
2828
"cakephp/chronos": "^2.0",
2929
"composer/composer": "^1.3 | ^2.0",
@@ -54,9 +54,16 @@
5454
"scripts": {
5555
"cs-check": "phpcs --colors --parallel=16 -p src/ tests/",
5656
"cs-fix": "phpcbf --colors --parallel=16 -p src/ tests/",
57-
"test": "phpunit",
57+
"phpstan": "phpstan.phar analyse",
5858
"psalm": "psalm.phar --show-info=false",
59-
"psalm-setup": "cp composer.json composer.backup && composer require --dev psalm/phar:^4.10 && mv composer.backup composer.json"
59+
"stan": [
60+
"@phpstan",
61+
"@psalm"
62+
],
63+
"stan-baseline": "phpstan.phar --generate-baseline",
64+
"psalm-baseline": "psalm.phar --set-baseline=psalm-baseline.xml",
65+
"stan-setup": "cp composer.json composer.backup && composer require --dev symfony/polyfill-php81 phpstan/phpstan:~1.7.0 psalm/phar:~4.23.0 && mv composer.backup composer.json",
66+
"test": "phpunit"
6067
},
6168
"prefer-stable": true,
6269
"config": {

Diff for: docs.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ FROM markstory/cakephp-docs-builder:runtime as runtime
1919

2020
# Configure search index script
2121
ENV LANGS="en fr ja pt"
22-
ENV SEARCH_SOURCE="/data/docs"
22+
ENV SEARCH_SOURCE="/usr/share/nginx/html"
2323
ENV SEARCH_URL_PREFIX="/debugkit/4"
2424

2525
COPY --from=builder /data/docs /data/docs

Diff for: phpstan-baseline.neon

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: "#^PHPDoc type array\\<string, mixed\\>\\|Cake\\\\Cache\\\\CacheEngine of property DebugKit\\\\Cache\\\\Engine\\\\DebugEngine\\:\\:\\$_config is not covariant with PHPDoc type array\\<string, mixed\\> of overridden property Cake\\\\Cache\\\\CacheEngine\\:\\:\\$_config\\.$#"
5+
count: 1
6+
path: src/Cache/Engine/DebugEngine.php
7+
8+
-
9+
message: "#^Property DebugKit\\\\Cache\\\\Engine\\\\DebugEngine\\:\\:\\$_engine \\(Cake\\\\Cache\\\\CacheEngine\\) in isset\\(\\) is not nullable\\.$#"
10+
count: 1
11+
path: src/Cache/Engine/DebugEngine.php
12+
13+
-
14+
message: "#^Unreachable statement \\- code above always terminates\\.$#"
15+
count: 1
16+
path: src/Cache/Engine/DebugEngine.php
17+
18+
-
19+
message: "#^Call to function file_get_contents\\(\\) on a separate line has no effect\\.$#"
20+
count: 1
21+
path: src/Command/BenchmarkCommand.php
22+
23+
-
24+
message: "#^Method DebugKit\\\\Mailer\\\\Transport\\\\DebugKitTransport\\:\\:send\\(\\) should return array\\{headers\\: string, message\\: string\\} but returns array\\{headers\\: non\\-empty\\-array\\<string\\>, message\\: array\\{text\\: string, html\\: string\\}\\}\\.$#"
25+
count: 1
26+
path: src/Mailer/Transport/DebugKitTransport.php
27+
28+
-
29+
message: "#^Parameter \\#1 \\$request of method DebugKit\\\\ToolbarService\\:\\:saveData\\(\\) expects Cake\\\\Http\\\\ServerRequest, Psr\\\\Http\\\\Message\\\\ServerRequestInterface given\\.$#"
30+
count: 1
31+
path: src/Middleware/DebugKitMiddleware.php
32+
33+
-
34+
message: "#^Call to an undefined method Cake\\\\ORM\\\\Locator\\\\LocatorInterface\\:\\:genericInstances\\(\\)\\.$#"
35+
count: 1
36+
path: src/Panel/SqlLogPanel.php

Diff for: phpstan.neon

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 6
6+
checkMissingIterableValueType: false
7+
checkGenericClassInNonGenericObjectType: false
8+
treatPhpDocTypesAsCertain: false
9+
bootstrapFiles:
10+
- tests/bootstrap.php
11+
- vendor/cakephp/cakephp/src/Core/Exception/CakeException.php
12+
paths:
13+
- src/

Diff for: psalm-baseline.xml

-16
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
<code>new $className($config)</code>
4646
</PropertyTypeCoercion>
4747
</file>
48-
<file src="src/Middleware/DebugKitMiddleware.php">
49-
<ArgumentTypeCoercion occurrences="1">
50-
<code>$request</code>
51-
</ArgumentTypeCoercion>
52-
</file>
5348
<file src="src/Panel/DeprecationsPanel.php">
5449
<InvalidScalarArgument occurrences="4">
5550
<code>$pluginName</code>
@@ -66,11 +61,6 @@
6661
<code>$vendorName</code>
6762
</InvalidScalarArgument>
6863
</file>
69-
<file src="src/Panel/LogPanel.php">
70-
<UndefinedInterfaceMethod occurrences="1">
71-
<code>count</code>
72-
</UndefinedInterfaceMethod>
73-
</file>
7464
<file src="src/Panel/PanelRegistry.php">
7565
<LessSpecificImplementedReturnType occurrences="1">
7666
<code>string|null</code>
@@ -83,16 +73,10 @@
8373
</UnsafeInstantiation>
8474
</file>
8575
<file src="src/Panel/SqlLogPanel.php">
86-
<TypeDoesNotContainType occurrences="1">
87-
<code>!$connection instanceof ConnectionInterface</code>
88-
</TypeDoesNotContainType>
8976
<UndefinedInterfaceMethod occurrences="1">
9077
<code>genericInstances</code>
9178
</UndefinedInterfaceMethod>
9279
</file>
93-
<file src="src/Plugin.php">
94-
<InvalidArgument occurrences="1"/>
95-
</file>
9680
<file src="src/View/Helper/ToolbarHelper.php">
9781
<DeprecatedMethod occurrences="1">
9882
<code>makeNeatArray</code>

Diff for: psalm.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0"?>
22
<psalm
3-
totallyTyped="false"
4-
resolveFromConfigFile="true"
3+
reportMixedIssues="false"
54
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
65
xmlns="https://getpsalm.org/schema/config"
76
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"

Diff for: src/Cache/Engine/DebugEngine.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ class DebugEngine extends CacheEngine
2828
/**
2929
* Proxied cache engine config.
3030
*
31-
* @var array<string, mixed>
31+
* @var array<string, mixed>|\Cake\Cache\CacheEngine
32+
* @psalm-suppress NonInvariantDocblockPropertyType
3233
*/
3334
protected $_config;
3435

3536
/**
3637
* Proxied engine
3738
*
38-
* @var mixed
39+
* @var \Cake\Cache\CacheEngine
3940
*/
4041
protected $_engine;
4142

@@ -64,7 +65,7 @@ class DebugEngine extends CacheEngine
6465
/**
6566
* Constructor
6667
*
67-
* @param mixed $config Config data or the proxied adapter.
68+
* @param array<string, mixed>|\Cake\Cache\CacheEngine $config Config data or the proxied adapter.
6869
* @param string $name The name of the proxied cache engine.
6970
* @param \Psr\Log\LoggerInterface $logger Logger for collecting cache operation logs.
7071
*/
@@ -83,7 +84,7 @@ public function __construct($config, string $name, LoggerInterface $logger)
8384
*/
8485
public function init(array $config = []): bool
8586
{
86-
if (is_object($this->_config)) {
87+
if (!is_array($this->_config)) {
8788
$this->_engine = $this->_config;
8889

8990
return true;
@@ -311,7 +312,9 @@ public function getConfig(?string $key = null, $default = null)
311312
*/
312313
public function setConfig($key, $value = null, $merge = true)
313314
{
314-
return $this->_engine->setConfig($key, $value, $merge);
315+
$this->_engine->setConfig($key, $value, $merge);
316+
317+
return $this;
315318
}
316319

317320
/**
@@ -336,12 +339,14 @@ public function clearGroup(string $group): bool
336339
*/
337340
public function __toString()
338341
{
339-
if (!empty($this->_engine)) {
342+
/** @psalm-suppress RedundantPropertyInitializationCheck */
343+
if (isset($this->_engine)) {
340344
[$ns, $class] = namespaceSplit(get_class($this->_engine));
341345

342346
return str_replace('Engine', '', $class);
343347
}
344348

349+
/** @psalm-suppress UndefinedMethod */
345350
return $this->_config['className'];
346351
}
347352
}

Diff for: src/Controller/DashboardController.php

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function index()
6262
public function reset()
6363
{
6464
$this->request->allowMethod('post');
65+
/** @var \DebugKit\Model\Table\RequestsTable $requestsModel */
6566
$requestsModel = $this->fetchTable('DebugKit.Requests');
6667

6768
$requestsModel->Panels->deleteAll('1=1');

Diff for: src/Controller/MailPreviewController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function sent($panelId, $number)
9999
*
100100
* @param string $name The Mailer name
101101
* @param string $method The mailer preview method
102-
* @return \Psr\Http\Message\ResponseInterface|null
102+
* @return \Psr\Http\Message\ResponseInterface|void
103103
*/
104104
public function email($name, $method)
105105
{
@@ -150,13 +150,13 @@ protected function respondWithPart($email, $partType)
150150
{
151151
$part = $this->findPart($email, $partType);
152152

153-
if ($part === false) {
153+
if ($part === null) {
154154
throw new NotFoundException(__d('debug_kit', "Email part ''{0}'' not found in email", $partType));
155155
}
156156

157157
$response = $this->response->withType($partType);
158158
if ($partType === 'text') {
159-
$part = '<pre>' . (string)$part . '</pre>';
159+
$part = '<pre>' . $part . '</pre>';
160160
}
161161

162162
return $response->withStringBody($part);

Diff for: src/DebugSql.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static function sql(Query $query, $showValues = true, $showHtml = null, $
7373

7474
$sql = (string)$query;
7575
if ($showValues) {
76-
$sql = static::interpolate($sql, $query->getValueBinder()->bindings());
76+
$sql = self::interpolate($sql, $query->getValueBinder()->bindings());
7777
}
7878

7979
/** @var array $trace */
@@ -92,16 +92,16 @@ public static function sql(Query $query, $showValues = true, $showHtml = null, $
9292
$file = str_replace($search, '', $file);
9393
}
9494

95-
$template = static::$templateHtml;
95+
$template = self::$templateHtml;
9696
$sqlHighlight = true;
9797
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') || $showHtml === false) {
98-
$template = static::$templateText;
98+
$template = self::$templateText;
9999
$sqlHighlight = false;
100100
if ($file && $line) {
101101
$lineInfo = sprintf('%s (line %s)', $file, $line);
102102
}
103103
}
104-
if ($showHtml === null && $template !== static::$templateText) {
104+
if ($showHtml === null && $template !== self::$templateText) {
105105
$showHtml = true;
106106
}
107107

@@ -113,7 +113,7 @@ public static function sql(Query $query, $showValues = true, $showHtml = null, $
113113
);
114114

115115
if ($showHtml) {
116-
$template = static::$templateHtml;
116+
$template = self::$templateHtml;
117117
if ($file && $line) {
118118
$lineInfo = sprintf('<span><strong>%s</strong> (line <strong>%s</strong>)</span>', $file, $line);
119119
}

Diff for: src/Mailer/Transport/DebugKitTransport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DebugKitTransport extends AbstractTransport
1616
/**
1717
* The transport object this class is decorating
1818
*
19-
* @var \Cake\Mailer\AbstractTransport
19+
* @var \Cake\Mailer\AbstractTransport|null
2020
*/
2121
protected $originalTransport;
2222

0 commit comments

Comments
 (0)