Skip to content

Commit e9f0807

Browse files
authored
Merge pull request #325 from cakephp/update-tools
Upgrade phpstan/psalm
2 parents f474c62 + fd33e98 commit e9f0807

10 files changed

Lines changed: 61 additions & 50 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
with:
130130
home: ${{ runner.temp }}/.phive
131131
binPath: ${{ github.workspace }}/tools/phive
132-
trustGpgKeys: "CF1A108D0E7AE720,12CE0F1D262429A5"
132+
trustGpgKeys: "CF1A108D0E7AE720,12CE0F1D262429A5,51C67305FFC2E5C0"
133133

134134
- name: Run PHP CodeSniffer
135135
run: vendor/bin/phpcs --report=checkstyle src/ tests/ | cs2pr

.phive/phars.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="1.9.12" installed="1.9.12" location="./tools/phpstan" copy="false"/>
4-
<phar name="psalm" version="5.4.0" installed="5.4.0" location="./tools/psalm" copy="false"/>
3+
<phar name="phpstan" version="2.0.1" installed="2.0.1" location="./tools/phpstan" copy="true"/>
4+
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="true"/>
55
</phive>

.stickler.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

phpstan-baseline.neon

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Access to an undefined property Cake\\\\Datasource\\\\EntityInterface\\:\\:\\$version\\.$#"
4+
message: '#^Strict comparison using \!\=\= between string and array\{\} will always evaluate to true\.$#'
5+
identifier: notIdentical.alwaysTrue
6+
count: 1
7+
path: src/Document.php
8+
9+
-
10+
message: '#^Access to an undefined property Cake\\Datasource\\EntityInterface\:\:\$version\.$#'
11+
identifier: property.notFound
512
count: 1
613
path: src/Index.php
714

815
-
9-
message: "#^Method Cake\\\\ElasticSearch\\\\Query\\:\\:find\\(\\) should return static\\(Cake\\\\ElasticSearch\\\\Query\\<TSubject of array\\|Cake\\\\ElasticSearch\\\\Document\\>\\) but returns Cake\\\\ElasticSearch\\\\Query\\<Cake\\\\ElasticSearch\\\\Document\\>\\.$#"
16+
message: '#^Method Cake\\ElasticSearch\\Query\:\:find\(\) should return static\(Cake\\ElasticSearch\\Query\<TSubject of array\|Cake\\ElasticSearch\\Document\>\) but returns Cake\\ElasticSearch\\Query\<Cake\\ElasticSearch\\Document\>\.$#'
17+
identifier: return.type
1018
count: 1
1119
path: src/Query.php
1220

1321
-
14-
message: "#^PHPDoc tag @return with type Cake\\\\ElasticSearch\\\\Query\\<TSubject of array\\|Cake\\\\ElasticSearch\\\\Document\\> is not subtype of native type static\\(Cake\\\\ElasticSearch\\\\Query\\<TSubject of array\\|Cake\\\\ElasticSearch\\\\Document\\>\\)\\.$#"
22+
message: '#^PHPDoc tag @return with type Cake\\ElasticSearch\\Query\<TSubject of array\|Cake\\ElasticSearch\\Document\> is not subtype of native type static\(Cake\\ElasticSearch\\Query\<TSubject of array\|Cake\\ElasticSearch\\Document\>\)\.$#'
23+
identifier: return.phpDocType
1524
count: 1
1625
path: src/Query.php
26+
27+
-
28+
message: '#^Strict comparison using \!\=\= between mixed and null will always evaluate to true\.$#'
29+
identifier: notIdentical.alwaysTrue
30+
count: 1
31+
path: src/QueryBuilder.php

phpstan.neon

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ includes:
22
- phpstan-baseline.neon
33

44
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/
5+
level: 6
6+
paths:
7+
- src/
8+
bootstrapFiles:
9+
- tests/bootstrap.php
10+
ignoreErrors:
11+
- identifier: missingType.iterableValue
12+
- identifier: missingType.generics
13+

psalm-baseline.xml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="dev-master@">
2+
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
33
<file src="src/Datasource/Connection.php">
4-
<InvalidReturnStatement occurrences="1">
5-
<code>$this-&gt;_client-&gt;getConfig()</code>
4+
<InvalidReturnStatement>
5+
<code><![CDATA[$this->_client->getConfig()]]></code>
66
</InvalidReturnStatement>
7-
<InvalidReturnType occurrences="1">
8-
<code>array</code>
7+
<InvalidReturnType>
8+
<code><![CDATA[array]]></code>
99
</InvalidReturnType>
10-
<LessSpecificImplementedReturnType occurrences="1">
11-
<code>array</code>
10+
<LessSpecificImplementedReturnType>
11+
<code><![CDATA[array]]></code>
1212
</LessSpecificImplementedReturnType>
1313
</file>
1414
<file src="src/Index.php">
15-
<NoInterfaceProperties occurrences="5">
16-
<code>$entity-&gt;version</code>
17-
<code>$entity-&gt;id</code>
18-
<code>$entity-&gt;id</code>
19-
<code>$entity-&gt;id</code>
20-
<code>$entity-&gt;id</code>
15+
<NoInterfaceProperties>
16+
<code><![CDATA[$entity->id]]></code>
17+
<code><![CDATA[$entity->id]]></code>
18+
<code><![CDATA[$entity->id]]></code>
19+
<code><![CDATA[$entity->id]]></code>
20+
<code><![CDATA[$entity->version]]></code>
2121
</NoInterfaceProperties>
2222
</file>
2323
<file src="src/Marshaller.php">
24-
<InvalidDocblock occurrences="1">
25-
<code>public function one(array $data, array $options = []): Document</code>
26-
</InvalidDocblock>
27-
<NoInterfaceProperties occurrences="1">
28-
<code>$record-&gt;id</code>
24+
<NoInterfaceProperties>
25+
<code><![CDATA[$record->id]]></code>
2926
</NoInterfaceProperties>
3027
</file>
3128
<file src="src/Query.php">
32-
<InvalidArgument occurrences="3">
33-
<code>$query</code>
34-
<code>$query</code>
35-
<code>false</code>
36-
</InvalidArgument>
37-
<LessSpecificImplementedReturnType occurrences="1">
38-
<code>\Traversable</code>
29+
<LessSpecificImplementedReturnType>
30+
<code><![CDATA[\Traversable]]></code>
3931
</LessSpecificImplementedReturnType>
4032
</file>
33+
<file src="src/View/Form/DocumentContext.php">
34+
<InvalidReturnStatement>
35+
<code><![CDATA[$entity]]></code>
36+
</InvalidReturnStatement>
37+
</file>
4138
</files>

psalm.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
88
autoloader="tests/bootstrap.php"
99
usePhpDocMethodsWithoutMagicCall="true"
10-
errorBaseline="psalm-baseline.xml"
10+
errorBaseline="./psalm-baseline.xml"
11+
findUnusedPsalmSuppress="true"
12+
findUnusedBaselineEntry="true"
13+
findUnusedCode="false"
1114
>
1215
<projectFiles>
1316
<directory name="src" />

src/Marshaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(Index $index)
5959
*
6060
* @param array $data The data to hydrate.
6161
* @param array $options List of options
62-
* @return \Cake\ElasticSearch\Document;
62+
* @return \Cake\ElasticSearch\Document
6363
*/
6464
public function one(array $data, array $options = []): Document
6565
{

src/Query.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,6 @@ public function formatResults(?Closure $formatter = null, int|bool $mode = self:
10651065
$this->_formatters = [];
10661066
}
10671067
if ($formatter === null) {
1068-
/** @psalm-suppress RedundantCondition */
10691068
if ($mode !== self::OVERWRITE) {
10701069
throw new InvalidArgumentException('$formatter can be null only when $mode is overwrite.');
10711070
}

tests/TestCase/View/Form/DocumentContextTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,13 @@ public function testErrorNestedFields()
537537
],
538538
'en' => [
539539
['family_name' => 'ZZ', 'given_name' => 'AA'],
540-
]
541-
]
540+
],
541+
],
542542
]);
543543
$row->setError('name', [
544544
'ja' => [
545-
['family_name' => ['_empty' => 'Invalid value']]
546-
]
545+
['family_name' => ['_empty' => 'Invalid value']],
546+
],
547547
]);
548548

549549
$articles = $this->setupIndex();

0 commit comments

Comments
 (0)