diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 179a2d9..8294b8f 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -19,8 +19,6 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - name: Cache Composer packages id: composer-cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1741a11..8111831 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,10 @@ jobs: - 'low' php: - '8.2' + - '8.3' + - '8.4' + - '8.5' + - '8.6-dev' steps: - name: Check out code diff --git a/composer.json b/composer.json index e471895..f463b14 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "php": "^8.2" }, "require-dev": { - "phpstan/phpstan": "^0.12.32", - "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", "phpunit/phpunit": "^11.0 || ^12.0 || ^13.0", "squizlabs/php_codesniffer": "^4.0" }, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 353be27..581fb5a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,27 +1,205 @@ parameters: ignoreErrors: - - message: "#^Method Firehed\\\\Input\\\\Exceptions\\\\InputException\\:\\:__construct\\(\\) has parameter \\$errors with no value type specified in iterable type array\\.$#" + message: '#^Binary operation "\." between non\-falsy\-string and mixed results in an error\.$#' + identifier: binaryOp.invalid + count: 2 + path: src/Containers/ParsedInput.php + + - + message: '#^Cannot access offset \(int\|string\) on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 1 + path: src/Containers/ParsedInput.php + + - + message: '#^Cannot access offset string on mixed\.$#' + identifier: offsetAccess.nonOffsetAccessible + count: 2 + path: src/Containers/ParsedInput.php + + - + message: '#^Method Firehed\\Input\\Containers\\ParsedInput\:\:asArray\(\) should return array\ but returns mixed\.$#' + identifier: return.type + count: 1 + path: src/Containers/ParsedInput.php + + - + message: '#^Parameter \#1 \$array of function array_keys expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/Containers/ParsedInput.php + + - + message: '#^Parameter \#1 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/Containers/ParsedInput.php + + - + message: '#^Parameter \#2 \$array of function array_key_exists expects array, mixed given\.$#' + identifier: argument.type + count: 3 + path: src/Containers/ParsedInput.php + + - + message: '#^Parameter \#2 \.\.\.\$arrays of function array_merge expects array, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/Containers/ParsedInput.php + + - + message: '#^Parameter \#1 \$data of class Firehed\\Input\\Containers\\ParsedInput constructor expects array\, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/Containers/RawInput.php + + - + message: '#^Parameter \#1 \$raw_input of method Firehed\\Input\\Interfaces\\ParserInterface\:\:parse\(\) expects string, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/Containers/RawInput.php + + - + message: '#^Parameter \#1 \$data of method Firehed\\Input\\Containers\\ParsedInput\:\:__construct\(\) expects array\, mixed given\.$#' + identifier: argument.type + count: 1 + path: src/Containers/SafeInput.php + + - + message: '#^Method Firehed\\Input\\Exceptions\\InputException\:\:__construct\(\) has parameter \$errors with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: src/Exceptions/InputException.php + + - + message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$invalid \(array\\) does not accept array\.$#' + identifier: assign.propertyType + count: 1 + path: src/Exceptions/InputException.php + + - + message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$invalid \(array\\) does not accept mixed\.$#' + identifier: assign.propertyType + count: 1 + path: src/Exceptions/InputException.php + + - + message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$missing \(array\\) does not accept array\.$#' + identifier: assign.propertyType + count: 1 + path: src/Exceptions/InputException.php + + - + message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$missing \(array\\) does not accept mixed\.$#' + identifier: assign.propertyType + count: 1 + path: src/Exceptions/InputException.php + + - + message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$unexpected \(array\\) does not accept array\.$#' + identifier: assign.propertyType + count: 1 + path: src/Exceptions/InputException.php + + - + message: '#^Property Firehed\\Input\\Exceptions\\InputException\:\:\$unexpected \(array\\) does not accept mixed\.$#' + identifier: assign.propertyType count: 1 path: src/Exceptions/InputException.php - - message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:nestedValidationExceptions\\(\\) has no return typehint specified\\.$#" + message: '#^Call to function is_array\(\) with array\\|string\> will always evaluate to true\.$#' + identifier: function.alreadyNarrowedType + count: 1 + path: src/Parsers/URLEncoded.php + + - + message: '#^Trait Firehed\\Input\\SafeInputTestTrait is used zero times and is not analysed\.$#' + identifier: trait.unused count: 1 + path: src/SafeInputTestTrait.php + + - + message: '#^Trait Firehed\\Input\\ValidationTestTrait is used zero times and is not analysed\.$#' + identifier: trait.unused + count: 1 + path: src/ValidationTestTrait.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input\\\\Containers\\\\SafeInput'' and Firehed\\Input\\Containers\\SafeInput will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 3 path: tests/Containers/ParsedInputTest.php - - message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:testValidateHandlesInputExceptions\\(\\) has parameter \\$invalid with no value type specified in iterable type array\\.$#" + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input…'' and Firehed\\Input\\Containers\\SafeInput will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 3 + path: tests/Containers/ParsedInputTest.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input…'', Firehed\\Input\\Containers\\ParsedInput and ''Construct failed'' will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType count: 1 path: tests/Containers/ParsedInputTest.php - - message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:testValidateHandlesInputExceptions\\(\\) has parameter \\$missing with no value type specified in iterable type array\\.$#" + message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:nestedValidationExceptions\(\) return type has no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Containers/ParsedInputTest.php - - message: "#^Method Firehed\\\\Input\\\\Containers\\\\ParsedInputTest\\:\\:testValidateHandlesInputExceptions\\(\\) has parameter \\$unexpected with no value type specified in iterable type array\\.$#" + message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:testValidateHandlesInputExceptions\(\) has parameter \$invalid with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 path: tests/Containers/ParsedInputTest.php + - + message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:testValidateHandlesInputExceptions\(\) has parameter \$missing with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: tests/Containers/ParsedInputTest.php + + - + message: '#^Method Firehed\\Input\\Containers\\ParsedInputTest\:\:testValidateHandlesInputExceptions\(\) has parameter \$unexpected with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue + count: 1 + path: tests/Containers/ParsedInputTest.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input…'', Firehed\\Input\\Containers\\ParsedInput and ''RawInput\:\:parse\(\)…'' will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 1 + path: tests/Containers/RawInputTest.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input…'', Firehed\\Input\\Containers\\RawInput and ''Construct failed'' will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 1 + path: tests/Containers/RawInputTest.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input\\\\Containers\\\\SafeInput'' and Firehed\\Input\\Containers\\SafeInput will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 1 + path: tests/Containers/SafeInputTest.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with arguments ''Firehed\\\\Input\\\\Exceptions\\\\InputException'', Firehed\\Input\\Exceptions\\InputException and non\-falsy\-string will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 1 + path: tests/Exceptions/InputExceptionTest.php + + - + message: '#^Dead catch \- LogicException is never thrown in the try block\.$#' + identifier: catch.neverThrown + count: 1 + path: tests/Exceptions/InputExceptionTest.php + + - + message: '#^Call to method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Firehed\\\\Input\\\\Objects\\\\InputObject'' and Firehed\\Input\\Objects\\InputObject will always evaluate to true\.$#' + identifier: method.alreadyNarrowedType + count: 1 + path: tests/Objects/InputObjectTest.php diff --git a/phpstan.neon b/phpstan.neon.dist similarity index 73% rename from phpstan.neon rename to phpstan.neon.dist index 2a4ecd7..4d046ab 100644 --- a/phpstan.neon +++ b/phpstan.neon.dist @@ -1,10 +1,10 @@ +# vim: ft=yaml includes: - phpstan-baseline.neon - vendor/phpstan/phpstan-phpunit/extension.neon parameters: - excludes_analyse: - - vendor level: max paths: - - src - - tests + - . + excludePaths: + - vendor