Skip to content

Test loose comparison on constant types#3755

Merged
ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
staabm:constloose
Jan 4, 2025
Merged

Test loose comparison on constant types#3755
ondrejmirtes merged 1 commit intophpstan:2.1.xfrom
staabm:constloose

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Dec 25, 2024

No description provided.

@staabm staabm force-pushed the constloose branch 3 times, most recently from 4db6522 to 9e3d1d3 Compare December 25, 2024 10:55
Comment on lines +663 to +765
assertType('false', 5 == $emptyStr);
assertType('false', 5 == $phpStr);
assertType('false', 5 == 'a');

assertType('false', $emptyStr == 5);
assertType('false', $phpStr == 5);
assertType('false', 'a' == 5);
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 ($this->isIterableAtLeastOnce()->no() && count($type->getConstantScalarValues()) === 1) {
// @phpstan-ignore equal.invalid, equal.notAllowed
return new ConstantBooleanType($type->getConstantScalarValues()[0] == []); // phpcs:ignore
if ($type->isInteger()->yes()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

mirrored from ArrayType

@staabm staabm force-pushed the constloose branch 3 times, most recently from a85f37a to 6fcbe71 Compare December 25, 2024 19:11
Comment on lines +720 to +828
assertType('false', $emptyArr == $looseOne);
assertType('bool', $emptyArr == $constMix);
assertType('bool', $emptyArr == $looseZero);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ondrejmirtes ondrejmirtes merged commit 7807722 into phpstan:2.1.x Jan 4, 2025
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the constloose branch January 4, 2025 13:55
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