Add ArrayCombineFunctionThrowTypeExtension#4414
Add ArrayCombineFunctionThrowTypeExtension#4414VincentLanglet merged 6 commits intophpstan:2.1.xfrom
Conversation
df20bcb to
97ced60
Compare
|
This pull request has been marked as ready for review. |
85cf058 to
c8ad51e
Compare
7e56be1 to
9e50bc1
Compare
9e50bc1 to
8d4a119
Compare
| return TypeCombinator::union(...$results); | ||
| } | ||
| [$returnType, $hasValueError] = $this->arrayCombineHelper->getReturnAndThrowType($firstArg, $secondArg, $scope); | ||
| if ($hasValueError->no()) { |
There was a problem hiding this comment.
If $hasValueError is MAYBE and throwsValueErrorForInternalFunctions is FALSE, we have to add new ConstantBooleanType(false).
The mutator think there is an escaped mutant because it only runs on PHP >= 80000
| $secondArg = $funcCall->getArgs()[1]->value; | ||
|
|
||
| $hasValueError = $this->arrayCombineHelper->getReturnAndThrowType($firstArg, $secondArg, $scope)[1]; | ||
| if (!$hasValueError->no()) { |
There was a problem hiding this comment.
I don't understand the "escaped mutant" since if ($hasValueError->yes()) { is failing locally
There was a problem hiding this comment.
cc @staabm since I think you introduced those mutant checks
There was a problem hiding this comment.
if you are getting a mutant for TrinaryLogic->yes(), !TrinaryLogic->no() or the inverses of it, it means you do not have a test for TrinaryLogic->maybe().
btw: there can be situations where we need to accept a mutant, because it might be not a valid combination of things or its untestable (or infection is not smart enough to detect a certain situation is logically impossible)
There was a problem hiding this comment.
if you are getting a mutant for TrinaryLogic->yes(), !TrinaryLogic->no() or the inverses of it, it means you do not have a test for TrinaryLogic->maybe().
I meant that I when I tried the mutation locally yesterday, the test were failing so I were surprised it was considered as an escaped mutation... Cause mixed is MAYBE so it should be already tested.
| /** | ||
| * @return array{Type, TrinaryLogic} The return type and if a ValueError may occur on PHP8 (and a warning on PHP7). | ||
| */ | ||
| public function getReturnAndThrowType(Expr $firstArg, Expr $secondArg, Scope $scope): array |
There was a problem hiding this comment.
I just basically extracted the existing code from ArrayCombineFunctionReturnTypeExtension ; solving the existing mutants are out of the scope of this PR.
Closes phpstan/phpstan#13642