Skip to content

Commit

Permalink
Raise PSALM to maximum level (#580)
Browse files Browse the repository at this point in the history
* Raise PSALM to maximum level

* Run PHPCS on 7.4

* Remove infection

* Update MSI

* Update MSI
  • Loading branch information
Slamdunk committed Jan 21, 2021
1 parent 1464569 commit 997e611
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 186 deletions.
25 changes: 12 additions & 13 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/composer-require-checker.json export-ignore
/box.json.dist export-ignore
/Makefile export-ignore
/infection.json.dist export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/.github/ export-ignore
/test/ export-ignore
/.github/ export-ignore
/test/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/Makefile export-ignore
/infection.json.dist export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/psalm.xml.dist export-ignore
/psalm-baseline.xml export-ignore
11 changes: 6 additions & 5 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
run: "composer-normalize --dry-run"

- name: "Check composer.json explicit dependencies"
run: "composer-require-checker check --config-file=$(realpath composer-require-checker.json)"
run: "composer-require-checker check"

- name: "Check composer.json unused dependencies"
run: "composer-unused"
Expand Down Expand Up @@ -135,6 +135,9 @@ jobs:
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-

- name: "Remove infection"
run: "composer remove --no-progress --no-update --no-scripts --dev 'infection/infection'"

- name: "Remove 'ext-posix' dep for Windows testing"
if: ${{ matrix.os == 'windows-latest' }}
run: "composer remove --no-progress --no-update --no-scripts --dev 'ext-posix'"
Expand Down Expand Up @@ -222,7 +225,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.3"
- "7.4"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -291,6 +294,4 @@ jobs:
run: "vendor/bin/phpstan analyse --no-progress --error-format=checkstyle | cs2pr"

- name: "Run PSalm for type-coverage"
run: |
vendor/bin/psalm --set-baseline=psalm-baseline.xml --no-progress --show-info=false > /dev/null || true
vendor/bin/psalm --set-baseline=psalm-baseline.xml --no-progress --shepherd --show-info=false --stats
run: "vendor/bin/psalm --no-progress --shepherd --output-format=github --show-info=false --stats"
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@ csfix: vendor
.PHONY: static-analysis
static-analysis: vendor
vendor/bin/phpstan analyse
vendor/bin/psalm --set-baseline=psalm-baseline.xml
vendor/bin/psalm

.PHONY: test
test: vendor
php -d zend.assertions=1 vendor/bin/phpunit --coverage-xml=coverage/coverage-xml --log-junit=coverage/junit.xml ${arg}
php -d zend.assertions=1 vendor/bin/phpunit \
--coverage-xml=coverage/coverage-xml \
--coverage-html=coverage/html \
--log-junit=coverage/junit.xml \
${arg}

.PHONY: code-coverage
code-coverage: test
php -d zend.assertions=1 vendor/bin/infection --threads=$(shell nproc) --coverage=coverage --skip-initial-tests
php -d zend.assertions=1 vendor/bin/infection \
--threads=$(shell nproc) \
--coverage=coverage \
--skip-initial-tests
14 changes: 0 additions & 14 deletions box.json.dist

This file was deleted.

7 changes: 0 additions & 7 deletions composer-require-checker.json

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"doctrine/coding-standard": "^8.2.0",
"ekino/phpstan-banned-code": "^0.3.1",
"ergebnis/phpstan-rules": "^0.15.3",
"infection/infection": "^0.18.2",
"infection/infection": "^0.20.2",
"phpstan/phpstan": "^0.12.64",
"phpstan/phpstan-deprecation-rules": "^0.12.6",
"phpstan/phpstan-phpunit": "^0.12.17",
Expand Down
4 changes: 2 additions & 2 deletions infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"assert\\(.+\\);"
]
},
"minMsi": 82,
"minCoveredMsi": 83
"minMsi": 83,
"minCoveredMsi": 84
}
245 changes: 245 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
parameters:
ignoreErrors:
-
message: "#^Should not use node with type \"Expr_Exit\", please change the code\\.$#"
count: 2
path: bin/paratest

-
message: "#^Should not use node with type \"Stmt_Echo\", please change the code\\.$#"
count: 1
path: bin/paratest

-
message: "#^Should not use node with type \"Expr_Exit\", please change the code\\.$#"
count: 2
path: bin/phpunit-wrapper.php

-
message: "#^Variable property access on SimpleXMLElement\\.$#"
count: 1
path: src/Logging/JUnit/TestCase.php

-
message: "#^Variable property access on ParaTest\\\\Logging\\\\JUnit\\\\TestCase\\.$#"
count: 1
path: src/Logging/JUnit/TestCase.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: src/Logging/JUnit/Writer.php

-
message:
"""
#^Instantiation of deprecated class PHPUnit\\\\Runner\\\\StandardTestSuiteLoader\\:
see https\\://github\\.com/sebastianbergmann/phpunit/issues/4039$#
"""
count: 1
path: src/Parser/Parser.php

-
message: "#^Only booleans are allowed in a negated boolean, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Only booleans are allowed in an if condition, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#1 \\$configuration of static method ParaTest\\\\Runners\\\\PHPUnit\\\\Options\\:\\:guessConfigurationFile\\(\\) expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Only booleans are allowed in \\|\\|, array\\<string\\>\\|bool\\|int\\|string\\|null given on the left side\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#1 \\$bootstrap of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#2 \\$colors of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects bool, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#4 \\$coverageClover of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#5 \\$coverageCobertura of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#6 \\$coverageCrap4j of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#7 \\$coverageHtml of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#8 \\$coveragePhp of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Cannot cast array\\<string\\>\\|bool\\|int\\|string\\|null to int\\.$#"
count: 3
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#10 \\$coverageText of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects bool, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#11 \\$coverageXml of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#14 \\$filter of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#15 \\$filtered of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects array\\<string, string\\|null\\>, array\\<string, array\\<string\\>\\|bool\\|int\\|string\\|null\\> given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#16 \\$functional of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects bool, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#18 \\$logJunit of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#19 \\$logTeamcity of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#21 \\$noTestTokens of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects bool, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#22 \\$parallelSuite of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects bool, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#1 \\$param of static method ParaTest\\\\Runners\\\\PHPUnit\\\\Options\\:\\:parsePassthru\\(\\) expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 2
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#25 \\$path of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#27 \\$processes of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects int, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#28 \\$runner of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#29 \\$stopOnFailure of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects bool, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#31 \\$tmpDir of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#33 \\$whitelist of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string\\|null, array\\<string\\>\\|bool\\|int\\|string\\|null given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^Parameter \\#34 \\$orderBy of class ParaTest\\\\Runners\\\\PHPUnit\\\\Options constructor expects string, array\\<string\\>\\|bool\\|int\\|string given\\.$#"
count: 1
path: src/Runners/PHPUnit/Options.php

-
message: "#^In method \"ParaTest\\\\Runners\\\\PHPUnit\\\\SuiteLoader\\:\\:getMethodTests\", caught \"Throwable\" must be rethrown\\. Either catch a more specific exception or add a \"throw\" clause in the \"catch\" block to propagate the exception\\. More info\\: http\\://bit\\.ly/failloud$#"
count: 1
path: src/Runners/PHPUnit/SuiteLoader.php

-
message:
"""
#^Usage of deprecated trait PHPUnit\\\\Framework\\\\TestListenerDefaultImplementation in class ParaTest\\\\Runners\\\\PHPUnit\\\\Worker\\\\NullPhpunitPrinter\\:
The `TestListener` interface is deprecated$#
"""
count: 1
path: src/Runners/PHPUnit/Worker/NullPhpunitPrinter.php

-
message: "#^Property ParaTest\\\\Runners\\\\PHPUnit\\\\Worker\\\\RunnerWorker\\:\\:\\$process type has no value type specified in iterable type Symfony\\\\Component\\\\Process\\\\Process\\.$#"
count: 1
path: src/Runners/PHPUnit/Worker/RunnerWorker.php

-
message: "#^Property ParaTest\\\\Runners\\\\PHPUnit\\\\Worker\\\\WrapperWorker\\:\\:\\$process type has no value type specified in iterable type Symfony\\\\Component\\\\Process\\\\Process\\.$#"
count: 1
path: src/Runners/PHPUnit/Worker/WrapperWorker.php

-
message: "#^Property ParaTest\\\\Runners\\\\PHPUnit\\\\Worker\\\\WrapperWorker\\:\\:\\$input type has no value type specified in iterable type Symfony\\\\Component\\\\Process\\\\InputStream\\.$#"
count: 1
path: src/Runners/PHPUnit/Worker/WrapperWorker.php

-
message: "#^Method ParaTest\\\\Runners\\\\PHPUnit\\\\WorkerCrashedException\\:\\:fromProcess\\(\\) has parameter \\$process with no value type specified in iterable type Symfony\\\\Component\\\\Process\\\\Process\\.$#"
count: 1
path: src/Runners/PHPUnit/WorkerCrashedException.php

-
message: "#^Method ParaTest\\\\Tests\\\\TestBase\\:\\:setUpTest\\(\\) is not final, but since the containing class is abstract, it should be\\.$#"
count: 1
path: test/TestBase.php

-
message: "#^Offset 'TEST_TOKEN' does not exist on array\\('PARATEST' \\=\\> 1, \\?'TEST_TOKEN' \\=\\> int, \\?'UNIQUE_TEST_TOKEN' \\=\\> string\\)\\.$#"
count: 1
path: test/Unit/Runners/PHPUnit/OptionsTest.php

-
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertIsString\\(\\) with string will always evaluate to true\\.$#"
count: 1
path: test/Unit/Runners/PHPUnit/OptionsTest.php

-
message: "#^Offset 'UNIQUE_TEST_TOKEN' does not exist on array\\('PARATEST' \\=\\> 1, \\?'UNIQUE_TEST_TOKEN' \\=\\> string, 'TEST_TOKEN' \\=\\> int\\)\\.$#"
count: 1
path: test/Unit/Runners/PHPUnit/OptionsTest.php

-
message: "#^Method ParaTest\\\\Tests\\\\Unit\\\\Runners\\\\PHPUnit\\\\SuiteLoaderTest\\:\\:getLoadedPaths\\(\\) should return array\\<string\\> but returns array\\<int, int\\|string\\>\\.$#"
count: 1
path: test/Unit/Runners/PHPUnit/SuiteLoaderTest.php

Loading

0 comments on commit 997e611

Please sign in to comment.