Skip to content

Re-use ExpressionTypeHolder#4832

Merged
ondrejmirtes merged 2 commits intophpstan:2.1.xfrom
staabm:reuse-holders
Jan 29, 2026
Merged

Re-use ExpressionTypeHolder#4832
ondrejmirtes merged 2 commits intophpstan:2.1.xfrom
staabm:reuse-holders

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Jan 29, 2026

No description provided.

}
}

$expressionTypes[$variableExprString] = ExpressionTypeHolder::createYes($use->var, $variableType);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't create 2 holders when not necessary


$holder = new ConditionalExpressionHolder([
$parameterType->getParameterName() => ExpressionTypeHolder::createYes(new Variable($targetParameterName), TypeCombinator::remove($targetParameter->getType(), $parameterType->getTarget())),
], new ExpressionTypeHolder(new Variable($parameter->getName()), $elseType, TrinaryLogic::createYes()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just cosmetic

$arrayDimFetchConditionalHolders = [];
foreach ($constantArrays[0]->getKeyTypes() as $i => $keyType) {
$valueType = $constantArrays[0]->getValueTypes()[$i];
$keyExpressionTypeHolder = ExpressionTypeHolder::createYes(new Variable($stmt->keyVar->name), $keyType);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't create 2 holders


$holder = new ConditionalExpressionHolder(
$conditions,
new ExpressionTypeHolder($expr, TypeCombinator::intersect($scope->getType($expr), $type), TrinaryLogic::createYes()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cosmetics

@staabm staabm closed this Jan 29, 2026
@staabm staabm deleted the reuse-holders branch January 29, 2026 11:00
@staabm staabm restored the reuse-holders branch January 29, 2026 11:00
@staabm staabm reopened this Jan 29, 2026
@staabm
Copy link
Contributor Author

staabm commented Jan 29, 2026

accidentally closed

@ondrejmirtes ondrejmirtes merged commit cd5401f into phpstan:2.1.x Jan 29, 2026
1241 of 1279 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the reuse-holders branch January 29, 2026 11:19
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.

2 participants