You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
typehint for range() does not suggest string[] #1201
This is weird, can you please follow the guidelines, post a phpstan.org
reproduction and add an expected output? I also don’t understand the note
sblut range() function and how that’s related.
On Wed, 11 Jul 2018 at 03:09, Alexey Kopytko ***@***.***> wrote:
For this code:
$allLines = range($input['startLine'], $input['endLine']);foreach ($allLines as $lineIn) { if (array_key_exists($lineIn, $this->example)) { // ...
I'm getting:
Parameter #1 <#1> $key of function
array_key_exists expects int|string, float|int given.
But there's a slight problem: range() may return an array of strings
<http://php.net/manual/en/function.range.php> just as well.
var_dump(range('c', 'a'));// outputs array('c', 'b', 'a')
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1201>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuFKDSLmtC3Qx01qG8UhL0G7spp3Uks5uFVAygaJpZM4VKVsc>
.
Activity
[-]typehint for range() does not suggest string[/-][+]typehint for range() does not suggest string[][/+]ondrejmirtes commentedon Jul 11, 2018
sanmai commentedon Jul 11, 2018
I've added a link to the reproduction.
range()returns array of either floats, ints, or strings, but PHPStan thinks it can only be of numbers.adaamz commentedon Jul 11, 2018
@ondrejmirtes Dynamic return type extension really returns type array<int, int|flost>, see
phpstan/src/Type/Php/RangeFunctionReturnTypeExtension.php
Line 103 in 40ece9a
Typehint for range() should suggest string[] where appropriate
Typehint for range() should suggest string[] where appropriate
ondrejmirtes commentedon Feb 18, 2021
This is already fixed.
github-actions commentedon Apr 29, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.