-
Notifications
You must be signed in to change notification settings - Fork 551
Add ArrayCombineFunctionThrowTypeExtension #4414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.1.x
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the "escaped mutant" since if ($hasValueError->yes()) { is failing locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @staabm since I think you introduced those mutant checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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