Skip to content

Commit a189ff0

Browse files
[php] Configure Psalm 6 default settings findUnusedBaselineEntry, findUnusedCode (#234)
* [php] Configure Psalm 6 default settings This fixes a warning that outputs that we should be explicit about this setting. I picked enabling it as the solution. * [php] Configure new Psalm checks OFF We were not ready yet. These are now explicitly disabled, which takes care of the reminder message. * [php] Psalm annotate exception class props. This tells Psalm that these are a part of an expected API. * Misc clean up * Run `vendor/bin/psalm --no-cache --alter --issues=MissingParamType` * Bump "phpunit/phpunit": "^10.5" to minimum deps run doesn't use a version that is too old * Upgrade to latest phpunit.xml format * Set findUnusedBaselineEntry="false" and findUnusedCode="false" to suppress paslm warnings --------- Co-authored-by: M.P. Korstanje <[email protected]>
1 parent 8f8f33b commit a189ff0

6 files changed

+28
-22
lines changed

php/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"cucumber/messages": ">=19.1.4 <=24"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "^10.0",
21+
"phpunit/phpunit": "^10.5",
2222
"vimeo/psalm": "5.19.1",
2323
"friendsofphp/php-cs-fixer": "^3.51",
2424
"psalm/plugin-phpunit": "^0.18.0",

php/phpunit.xml

+11-19
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
4-
bootstrap="vendor/autoload.php"
5-
cacheDirectory=".phpunit.cache"
6-
executionOrder="depends,defects"
7-
beStrictAboutOutputDuringTests="true"
8-
failOnRisky="true"
9-
failOnWarning="true"
10-
beStrictAboutCoverageMetadata="true">
11-
<testsuites>
12-
<testsuite name="default">
13-
<directory>tests</directory>
14-
</testsuite>
15-
</testsuites>
16-
<coverage>
17-
<include>
18-
<directory suffix=".php">src</directory>
19-
</include>
20-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" failOnRisky="true" failOnWarning="true" beStrictAboutCoverageMetadata="true">
3+
<testsuites>
4+
<testsuite name="default">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<source>
9+
<include>
10+
<directory suffix=".php">src</directory>
11+
</include>
12+
</source>
2113
</phpunit>

php/psalm.xml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<psalm
33
errorLevel="1"
44
resolveFromConfigFile="true"
5+
findUnusedBaselineEntry="false"
6+
findUnusedCode="false"
57
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
68
xmlns="https://getpsalm.org/schema/config"
79
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"

php/src/AstNode.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,14 @@ public function getSingle(string $expectedType, RuleType $ruleType, ?object $def
6262
return $items[0] ?? $defaultValue;
6363
}
6464

65-
/** needed for non-object return */
66-
public function getSingleUntyped(RuleType $ruleType, mixed $defaultValue = null): mixed
65+
/**
66+
* needed for non-object return
67+
*
68+
* @param null|string $defaultValue
69+
*
70+
* @psalm-param ''|null $defaultValue
71+
*/
72+
public function getSingleUntyped(RuleType $ruleType, string|null $defaultValue = null): mixed
6773
{
6874
$items = $this->subItems[$ruleType->name] ?? [];
6975

php/src/ParserException/UnexpectedEofException.php

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
use Cucumber\Gherkin\ParserException;
88
use Cucumber\Gherkin\Token;
99

10+
/**
11+
* @psalm-api
12+
*/
1013
final class UnexpectedEofException extends ParserException
1114
{
1215
/**

php/src/ParserException/UnexpectedTokenException.php

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Cucumber\Gherkin\ParserException;
99
use Cucumber\Gherkin\Token;
1010

11+
/**
12+
* @psalm-api
13+
*/
1114
final class UnexpectedTokenException extends ParserException
1215
{
1316
/**

0 commit comments

Comments
 (0)