Skip to content

Commit 8259795

Browse files
authored
Fix CI tests (psalm) (#913)
* Display psalm version being run * Update exclusions * Use separate configuration for PHP 7.4 * Remove temporary workaround
1 parent c8a7bc9 commit 8259795

File tree

5 files changed

+119
-31
lines changed

5 files changed

+119
-31
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"phpcsstandards/phpcsutils": "@alpha",
3030
"phpstan/phpstan": "*",
3131
"phpunit/phpunit": "*",
32-
"squizlabs/php_codesniffer": "*"
32+
"squizlabs/php_codesniffer": "*",
33+
"vimeo/psalm": ">=5.26.1"
3334
},
3435
"suggest": {
3536
"ext-mbstring": "*"

tests/psalm.xml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,45 @@
1515
</ignoreFiles>
1616
</projectFiles>
1717
<issueHandlers>
18-
<UndefinedClass>
18+
<PossiblyUnusedMethod>
1919
<errorLevel type="suppress">
20-
<referencedClass name="CurlHandle" />
21-
<file name="../src/Curl/Curl.php" />
20+
<directory name="../src/" />
2221
</errorLevel>
22+
</PossiblyUnusedMethod>
23+
<PossiblyUnusedProperty>
2324
<errorLevel type="suppress">
24-
<referencedClass name="CurlMultiHandle" />
25-
<file name="../src/Curl/MultiCurl.php" />
25+
<directory name="../src/" />
2626
</errorLevel>
27+
</PossiblyUnusedProperty>
28+
<PossiblyUnusedReturnValue>
2729
<errorLevel type="suppress">
28-
<referencedClass name="CURLStringFile" />
29-
<file name="../src/Curl/ArrayUtil.php" />
30+
<directory name="../src/" />
3031
</errorLevel>
31-
</UndefinedClass>
32+
</PossiblyUnusedReturnValue>
33+
<UnusedClass>
34+
<errorLevel type="suppress">
35+
<directory name="../src/" />
36+
</errorLevel>
37+
</UnusedClass>
38+
<UnusedClosureParam>
39+
<errorLevel type="suppress">
40+
<directory name="../src/" />
41+
</errorLevel>
42+
</UnusedClosureParam>
43+
<UnusedForeachValue>
44+
<errorLevel type="suppress">
45+
<directory name="../src/" />
46+
</errorLevel>
47+
</UnusedForeachValue>
48+
<UnusedMethod>
49+
<errorLevel type="suppress">
50+
<directory name="../src/" />
51+
</errorLevel>
52+
</UnusedMethod>
53+
<UnusedProperty>
54+
<errorLevel type="suppress">
55+
<directory name="../src/" />
56+
</errorLevel>
57+
</UnusedProperty>
3258
</issueHandlers>
3359
</psalm>

tests/psalm_7.4.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0"?>
2+
<!-- TODO: Use errorLevel="1" -->
3+
<psalm
4+
errorLevel="4"
5+
resolveFromConfigFile="true"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xmlns="https://getpsalm.org/schema/config"
8+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
9+
errorBaseline="psalm-baseline.xml"
10+
>
11+
<projectFiles>
12+
<directory name="../src" />
13+
<ignoreFiles>
14+
<directory name="../vendor" />
15+
</ignoreFiles>
16+
</projectFiles>
17+
<issueHandlers>
18+
<PossiblyUnusedMethod>
19+
<errorLevel type="suppress">
20+
<directory name="../src/" />
21+
</errorLevel>
22+
</PossiblyUnusedMethod>
23+
<PossiblyUnusedProperty>
24+
<errorLevel type="suppress">
25+
<directory name="../src/" />
26+
</errorLevel>
27+
</PossiblyUnusedProperty>
28+
<PossiblyUnusedReturnValue>
29+
<errorLevel type="suppress">
30+
<directory name="../src/" />
31+
</errorLevel>
32+
</PossiblyUnusedReturnValue>
33+
<UndefinedClass>
34+
<errorLevel type="suppress">
35+
<referencedClass name="CurlHandle" />
36+
<file name="../src/Curl/Curl.php" />
37+
</errorLevel>
38+
<errorLevel type="suppress">
39+
<referencedClass name="CurlMultiHandle" />
40+
<file name="../src/Curl/MultiCurl.php" />
41+
</errorLevel>
42+
<errorLevel type="suppress">
43+
<referencedClass name="CURLStringFile" />
44+
<file name="../src/Curl/ArrayUtil.php" />
45+
</errorLevel>
46+
</UndefinedClass>
47+
<UnusedClass>
48+
<errorLevel type="suppress">
49+
<directory name="../src/" />
50+
</errorLevel>
51+
</UnusedClass>
52+
<UnusedClosureParam>
53+
<errorLevel type="suppress">
54+
<directory name="../src/" />
55+
</errorLevel>
56+
</UnusedClosureParam>
57+
<UnusedForeachValue>
58+
<errorLevel type="suppress">
59+
<directory name="../src/" />
60+
</errorLevel>
61+
</UnusedForeachValue>
62+
<UnusedMethod>
63+
<errorLevel type="suppress">
64+
<directory name="../src/" />
65+
</errorLevel>
66+
</UnusedMethod>
67+
<UnusedProperty>
68+
<errorLevel type="suppress">
69+
<directory name="../src/" />
70+
</errorLevel>
71+
</UnusedProperty>
72+
</issueHandlers>
73+
</psalm>

tests/run.sh

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@ set -x
44

55
if [[ "${CI}" == "true" ]]; then
66
composer self-update
7-
8-
# TODO: Add "vimeo/psalm" back into composer.json under "require-dev" when
9-
# vimeo/psalm supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107):
10-
# "require-dev": {
11-
# "vimeo/psalm": ">=5.26.1"
12-
# },
13-
#
14-
# TODO: Remove this workaround that only installs vimeo/psalm on PHP < 8.4 when
15-
# vimeo/psalm supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107):
16-
if [[ $(echo "${CI_PHP_VERSION} < 8.4" | bc -l) -eq 1 ]]; then
17-
composer require --dev "vimeo/psalm:>=5.26.1"
18-
fi
19-
207
composer install --prefer-source --no-interaction
218
fi
229

tests/run_static_analysis_check_psalm.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ pushd ..
1010

1111
set -x
1212

13-
# TODO: Remove exclusion that skips running psalm on PHP 8.4 when psalm
14-
# supports PHP 8.4 (https://github.com/vimeo/psalm/issues/11107).
15-
if [[ $(echo "${CI_PHP_VERSION} < 8.4" | bc -l) -eq 1 ]]; then
16-
vendor/bin/psalm --config="tests/psalm.xml"
17-
if [[ "${?}" -ne 0 ]]; then
18-
echo "Error: psalm static analysis check failed"
19-
errors+=("psalm static analysis check failed")
20-
fi
13+
vendor/bin/psalm --version
14+
15+
if [[ $(echo "${CI_PHP_VERSION} == 7.4" | bc -l) -eq 1 ]]; then
16+
vendor/bin/psalm --config="tests/psalm_7.4.xml"
2117
else
22-
echo "Skipped running psalm check"
18+
vendor/bin/psalm --config="tests/psalm.xml"
19+
fi
20+
21+
if [[ "${?}" -ne 0 ]]; then
22+
echo "Error: psalm static analysis check failed"
23+
errors+=("psalm static analysis check failed")
2324
fi
2425

2526
popd

0 commit comments

Comments
 (0)