Add support for integer ranges in strtotime() with constant strings#1045
Add support for integer ranges in strtotime() with constant strings#1045ondrejmirtes merged 2 commits intophpstan:masterfrom
Conversation
dac1c88 to
a1fb11d
Compare
There was a problem hiding this comment.
This yields:
57 Parameter #1 $value of static method
PHPStan\Type\IntegerRangeType::createAllGreaterThan() expects
float|int, int|false given.
But I don't get it, because $results is not empty, and so min() cannot return false.
Edit: fixed with a (int) cast for now.. but not pleased :)
There was a problem hiding this comment.
could the min value depend on the systems time-zone?
There was a problem hiding this comment.
Yes it does. I think it's mostly ok as the main point is to know if it's positive-int or int IMO. negative-int in dates are pretty rare.. The high precision requires you have a correctly set timezone, which sounds like an OK limitation to me but maybe it isnt?
There was a problem hiding this comment.
maybe
| assertType('int', $strtotimeWithBase); | |
| assertType('positive-int', $strtotimeWithBase); |
?
There was a problem hiding this comment.
Yes but that would require parsing the second argument properly, which I am not doing right now. Feel free to send a PR for that, it's beyond my skills here :D
3d0c903 to
ca5e927
Compare
ba41785 to
494a7f8
Compare
… unable to cause a false return
|
Thank you! |
I migrated the existing tests from legacy tests, I hope this makes sense.
I am trying to pass strtotime() to a
positive-intparam and figured this should just work :)The ranges are always
int<$oldestResolvedTime, max>as time flows forward, the result may increase but should not decrease.