Skip to content

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Nov 2, 2025

closes phpstan/phpstan#13749

if one of the involved function calls got already narrowed, switching the operands can lead to more precise types.

@staabm staabm marked this pull request as ready for review November 2, 2025 10:06
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

Comment on lines +2248 to +2259
// Normalize to: fn() === expr
if ($rightExpr instanceof FuncCall && !$leftExpr instanceof FuncCall) {
[$leftExpr, $rightExpr] = [$rightExpr, $leftExpr];
$specifiedTypes = $this->resolveNormalizedIdentical(new Expr\BinaryOp\Identical(
$rightExpr,
$leftExpr,
), $scope, $context);
} else {
$specifiedTypes = $this->resolveNormalizedIdentical(new Expr\BinaryOp\Identical(
$leftExpr,
$rightExpr,
), $scope, $context);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved already existing normalization logic here

}

// merge result of fn1() === fn2() and fn2() === fn1()
if ($rightExpr instanceof FuncCall && $leftExpr instanceof FuncCall) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the actual new logic

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.

infer non-empty-string on strlen() == strlen()

2 participants