-
Notifications
You must be signed in to change notification settings - Fork 510
RoundFunctionReturnTypeExtension supports types with ConstantScalar #3349
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: 1.12.x
Are you sure you want to change the base?
Conversation
465733b
to
276f471
Compare
which problem does this change solve? whats your real world use-case? |
} | ||
|
||
if (count($returnValueTypes) >= 1) { | ||
return TypeCombinator::union(...array_map(static fn ($l) => $l, $returnValueTypes)); |
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.
return TypeCombinator::union(...array_map(static fn ($l) => $l, $returnValueTypes)); | |
return TypeCombinator::union(...$returnValueTypes); |
I'm sure there are several use cases for this, but one I quickly spotted in my private code is the following pattern, which uses Ideally it would be even more useful if a float range type was implemented, but I feel like this is worthwhile enough on its own. const MAX = 1000;
const PER_PAGE = 30;
$last_page = (int)floor(MAX / PER_PAGE); |
98e7404
to
e4ad097
Compare
Returns a constant when
$num
parameter and option of the round function are constants.In this case , the conventional type is returned.
$num
parameter is a numeric string.$num
parameter union contains a numeric string.round()
option is not a constant.