Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

@VincentLanglet VincentLanglet commented Oct 6, 2025

@VincentLanglet VincentLanglet marked this pull request as draft October 6, 2025 13:36
@VincentLanglet VincentLanglet marked this pull request as ready for review October 6, 2025 15:21
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet VincentLanglet force-pushed the arrayCombine branch 4 times, most recently from 85cf058 to c8ad51e Compare December 5, 2025 14:19
return TypeCombinator::union(...$results);
}
[$returnType, $hasValueError] = $this->arrayCombineHelper->getReturnAndThrowType($firstArg, $secondArg, $scope);
if ($hasValueError->no()) {
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

@staabm staabm Feb 2, 2026

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)

Copy link
Contributor Author

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

array_combine throws ValueError false positive

3 participants