If the first numeric index of an array is negative let the next one stay negative#2383
If the first numeric index of an array is negative let the next one stay negative#2383pmmaga wants to merge 7 commits into
Conversation
|
Something that is documented, and that works the same in every released version of PHP (and hhvm) can't really be described as unexpected, or buggy. It's surprising at the most ... I think this needs an RFC to resolve it, so I'm going to label it as such ... at the very least it requires an internals discussion. |
Sorry, something went wrong.
|
Agreed. I'll start a discussion on internals later today. Thanks for the feedback! |
Sorry, something went wrong.
|
sorry guys, I didn't see this PR before I sent my one, but I have alternative approach to fix this. |
Sorry, something went wrong.
|
I don't think it's a thing that needs fixing (although it is wtfaf). At most, I'd say deprecate this method and introduce a new one, but even that feels heavy handed given how positively ancient this function is. |
Sorry, something went wrong.
|
@sgolemon, thanks for the feedback. If you check the implementation, you'll see that this change wouldn't be limited to the array_fill function but to all arrays where the first key is negative. So, in the scope of this implementation, deprecating a function/introducing a new one wouldn't really make sense. |
Sorry, something went wrong.
|
@pmmaga I am wondering how it will influence existing code which relies on previous version of array indexes? |
Sorry, something went wrong.
|
@andrewnester, yes, it would introduce a BC break in those cases. |
Sorry, something went wrong.
|
Looks like the latest changes broke the build completely... |
Sorry, something went wrong.
|
It did indeed. I didn't have the time to fix this today so I added the [WIP] to the title until I get it right again. |
Sorry, something went wrong.
2dc15a3 to
b55489f
Compare
March 9, 2017 19:56
|
Ok, I've managed to fix the issues and it's all green now. |
Sorry, something went wrong.
|
This definitely should not target PHP 7.2 as it breaks backward compatibility. |
Sorry, something went wrong.
|
'Documented but unexpected' doesn't make any sense to me? Changing documented behaviour is a clear BC break so this should target |
Sorry, something went wrong.
|
I'd rather see an extra param to |
Sorry, something went wrong.
|
see https://wiki.php.net/rfc/releaseprocess |
Sorry, something went wrong.
|
I find the current behaviour of |
Sorry, something went wrong.
b55489f to
dec8f3a
Compare
June 13, 2017 18:21
|
I have updated the RFC to target 8.0 and updated this PR to throw a |
Sorry, something went wrong.
dec8f3a to
34bb2da
Compare
June 14, 2017 17:34
34bb2da to
0250615
Compare
January 26, 2018 00:17
|
Following the vote on https://wiki.php.net/rfc/negative_array_index and given that the deprecation notice was rejected, I'm closing this PR. |
Sorry, something went wrong.
The current behavior of
array_fill(-10, 3, true)- although documented - is unexpected.This same behavior can also be seen in array declarations with an explicit negative index.
IMHO, this sits in a limbo between a bugfix and a language change. Or, in other words, it seems to me that the only reason why this would not be a bug would be the fact that it is documented.
Let me know what you think.
Link to the RFC: https://wiki.php.net/rfc/negative_array_index