Skip to content

Commit

Permalink
Upgrade PHPStan to the latest version and fix some errors (#1859)
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-rafalko committed May 14, 2023
1 parent 8284478 commit c026790
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 71 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"phpspec/prophecy-phpunit": "^2.0",
"phpspec/prophecy": "^1.15",
"phpstan/extension-installer": "^1.1.0",
"phpstan/phpstan": "^1.3.0",
"phpstan/phpstan": "^1.10.15",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpstan/phpstan-webmozart-assert": "^1.0.2",
Expand Down
34 changes: 16 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 39 additions & 11 deletions devTools/phpstan-src.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,10 @@ parameters:
- '#^Short ternary operator is not allowed\. Use null coalesce operator if applicable or consider using long ternary\.$#'
- '#^Dead catch - InvalidArgumentException is never thrown in the try block\.$#'
- '#^Variable (method|property) (access|call) #'
-
path: '../src/Metrics/MetricsCalculator.php'
message: '#^Strict comparison using !== between array<int|string, Infection\\Mutant\\MutantExecutionResult> and array{} will always evaluate to true\.$#'
count: 1
-
path: '../src/Mutator/MutatorResolver.php'
message: '#^Method Infection\\Mutator\\MutatorResolver::resolveSettings\(\) has parameter \$settings with no value type specified in iterable type array\.$#'
count: 1
-
path: ../src/TestFramework/Factory.php
message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(Infection\\TestFramework\\Coverage\\Trace\|SplFileInfo\): mixed\)\|null, Closure\(SplFileInfo\): string\|false given\.$#'
count: 1
-
path: ../src/TestFramework/Factory.php
message: '#^Parameter \#1 \$iterator of function iterator_to_array expects Traversable, iterable<Infection\\TestFramework\\Coverage\\Trace\|SplFileInfo> given\.$#'
Expand All @@ -34,9 +26,6 @@ parameters:
-
path: '../src/TestFramework/Coverage/CoverageChecker.php'
message: '#Function ini_get is unsafe to use#'
-
path: '../src/Differ/DiffChangedLinesParser.php'
message: '#Method Infection\\Differ\\DiffChangedLinesParser::parse\(\) should return array\<string, array\<int, Infection\\Differ\\ChangedLinesRange\>\>#'
-
path: '../src/Logger/Html/StrykerHtmlReportBuilder.php'
message: '#return type has no value type specified in iterable type array#'
Expand All @@ -49,6 +38,45 @@ parameters:
- # TODO: fix this; this was introduced as bumping to PHP 8.1 as the minimim requirement
message: '#^Parameter \#1 \$string of function trim expects string, string\|null given\.$#'
path: '../src/TestFramework/PhpUnit/Config/Path/PathReplacer.php'
-
message: "#^Instantiated class Infection\\\\FileSystem\\\\DummyFileSystem not found\\.$#"
count: 1
path: ../src/Container.php

-
message: "#^Parameter \\#5 \\$fileSystem of class Infection\\\\Process\\\\Runner\\\\MutationTestingRunner constructor expects Symfony\\\\Component\\\\Filesystem\\\\Filesystem, Infection\\\\FileSystem\\\\DummyFileSystem\\|Symfony\\\\Component\\\\Filesystem\\\\Filesystem given\\.$#"
count: 1
path: ../src/Container.php

-
message: "#^ArrayObject\\<\\*NEVER\\*, \\*NEVER\\*\\> does not accept array\\<string, array\\|string\\>\\.$#"
count: 1
path: ../src/Logger/Html/StrykerHtmlReportBuilder.php

-
message: "#^PHPDoc tag @var with type Infection\\\\Mutator\\\\Mutator\\<PhpParser\\\\NodeAbstract\\> is not subtype of native type 'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Assignment'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\AssignmentEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\BitwiseAnd'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\BitwiseNot'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\BitwiseOr'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\BitwiseXor'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Decrement'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\DivEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Division'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Exponentiation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Increment'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Minus'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\MinusEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\ModEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Modulus'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\MulEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Multiplication'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\Plus'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\PlusEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\PowEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\RoundingFamily'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\ShiftLeft'\\|'Infection\\\\\\\\Mutator\\\\\\\\Arithmetic\\\\\\\\ShiftRight'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\ArrayItem'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\EqualIdentical'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\FalseValue'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\IdenticalEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\InstanceOf_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalAnd'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalAndAllSubExprNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalAndNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalAndSingleSubExprNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalLowerAnd'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalLowerOr'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalNot'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalOr'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalOrAllSubExprNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalOrNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\LogicalOrSingleSubExprNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\NotEqualNotIdentical'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\NotIdenticalNotEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\TrueValue'\\|'Infection\\\\\\\\Mutator\\\\\\\\Boolean\\\\\\\\Yield_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Cast\\\\\\\\CastArray'\\|'Infection\\\\\\\\Mutator\\\\\\\\Cast\\\\\\\\CastBool'\\|'Infection\\\\\\\\Mutator\\\\\\\\Cast\\\\\\\\CastFloat'\\|'Infection\\\\\\\\Mutator\\\\\\\\Cast\\\\\\\\CastInt'\\|'Infection\\\\\\\\Mutator\\\\\\\\Cast\\\\\\\\CastObject'\\|'Infection\\\\\\\\Mutator\\\\\\\\Cast\\\\\\\\CastString'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalBoundary\\\\\\\\GreaterThan'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalBoundary\\\\\\\\GreaterThanOrEqualTo'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalBoundary\\\\\\\\LessThan'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalBoundary\\\\\\\\LessThanOrEqualTo'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\Equal'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\GreaterThanNegotiation'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\GreaterThanOrEqualToNegotiation'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\Identical'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\LessThanNegotiation'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\LessThanOrEqualToNegotiation'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\NotEqual'\\|'Infection\\\\\\\\Mutator\\\\\\\\ConditionalNegotiation\\\\\\\\NotIdentical'\\|'Infection\\\\\\\\Mutator\\\\\\\\Extensions\\\\\\\\BCMath'\\|'Infection\\\\\\\\Mutator\\\\\\\\Extensions\\\\\\\\MBString'\\|'Infection\\\\\\\\Mutator\\\\\\\\FunctionSignature\\\\\\\\ProtectedVisibility'\\|'Infection\\\\\\\\Mutator\\\\\\\\FunctionSignature\\\\\\\\PublicVisibility'\\|'Infection\\\\\\\\Mutator\\\\\\\\Loop\\\\\\\\DoWhile'\\|'Infection\\\\\\\\Mutator\\\\\\\\Loop\\\\\\\\For_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Loop\\\\\\\\Foreach_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Loop\\\\\\\\While_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Number\\\\\\\\DecrementInteger'\\|'Infection\\\\\\\\Mutator\\\\\\\\Number\\\\\\\\IncrementInteger'\\|'Infection\\\\\\\\Mutator\\\\\\\\Number\\\\\\\\OneZeroFloat'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\AssignCoalesce'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Break_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Catch_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Coalesce'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Concat'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Continue_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\ElseIfNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Finally_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\IfNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\NullSafeMethodCall'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\NullSafePropertyCall'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\SpreadAssignment'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\SpreadOneItem'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\SpreadRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Ternary'\\|'Infection\\\\\\\\Mutator\\\\\\\\Operator\\\\\\\\Throw_'\\|'Infection\\\\\\\\Mutator\\\\\\\\Regex\\\\\\\\PregMatchMatches'\\|'Infection\\\\\\\\Mutator\\\\\\\\Regex\\\\\\\\PregMatchRemoveCaret'\\|'Infection\\\\\\\\Mutator\\\\\\\\Regex\\\\\\\\PregMatchRemoveDollar'\\|'Infection\\\\\\\\Mutator\\\\\\\\Regex\\\\\\\\PregMatchRemoveFlags'\\|'Infection\\\\\\\\Mutator\\\\\\\\Regex\\\\\\\\PregQuote'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\ArrayItemRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\CatchBlockRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\CloneRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\ConcatOperandRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\FunctionCallRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\MatchArmRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\MethodCallRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\Removal\\\\\\\\SharedCaseRemoval'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\ArrayOneItem'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\FloatNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\FunctionCall'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\IntegerNegation'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\NewObject'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\This'\\|'Infection\\\\\\\\Mutator\\\\\\\\ReturnValue\\\\\\\\YieldValue'\\|'Infection\\\\\\\\Mutator\\\\\\\\Sort\\\\\\\\Spaceship'\\|'Infection\\\\\\\\Mutator\\\\\\\\SyntaxError'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayChangeKeyCase'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayChunk'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayColumn'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayCombine'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayDiff'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayDiffAssoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayDiffKey'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayDiffUassoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayDiffUkey'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayFilter'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayFlip'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayIntersect'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayIntersectAssoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayIntersectKey'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayIntersectUassoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayIntersectUkey'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayKeys'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayMap'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayMerge'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayMergeRecursive'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayPad'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayReduce'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayReplace'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayReplaceRecursive'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayReverse'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArraySlice'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArraySplice'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUdiff'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUdiffAssoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUdiffUassoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUintersect'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUintersectAssoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUintersectUassoc'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayUnique'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapArrayValues'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapFinally'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapLcFirst'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapLtrim'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapRtrim'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrIreplace'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrRepeat'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrReplace'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrRev'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrShuffle'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrToLower'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapStrToUpper'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapSubstr'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapTrim'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapUcFirst'\\|'Infection\\\\\\\\Mutator\\\\\\\\Unwrap\\\\\\\\UnwrapUcWords'\\.$#"
count: 1
path: ../src/Logger/Html/StrykerHtmlReportBuilder.php

-
message: "#^Generator expects value type list\\<PhpParser\\\\Node\\\\Stmt\\>, array\\<PhpParser\\\\Node\\\\Stmt\\> given\\.$#"
count: 1
path: ../src/Mutator/Unwrap/UnwrapFinally.php

-
message: "#^Generator expects value type list\\<PhpParser\\\\Node\\\\Stmt\\>, non\\-empty\\-array\\<PhpParser\\\\Node\\\\Stmt\\> given\\.$#"
count: 1
path: ../src/Mutator/Unwrap/UnwrapFinally.php

-
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(Infection\\\\TestFramework\\\\Coverage\\\\Trace\\|SplFileInfo\\)\\: mixed\\)\\|null, Closure\\(SplFileInfo\\)\\: \\(string\\|false\\) given\\.$#"
count: 1
path: ../src/TestFramework/Factory.php

-
message: "#^Method Infection\\\\TestFramework\\\\SafeDOMXPath\\:\\:query\\(\\) should return DOMNodeList\\<DOMElement\\> but returns DOMNodeList\\<DOMNode\\>\\.$#"
count: 1
path: ../src/TestFramework/SafeDOMXPath.php

level: 8
paths:
Expand Down

0 comments on commit c026790

Please sign in to comment.