doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Referenced page does not mention negative keys

Open adrolter opened this issue 1 year ago • 1 comments

From manual page: https://php.net/function.array-fill

The Notes section links to and mentions that the page about the array datatype has a detailed explanation about negative keys, but the page makes no reference to the word "negative" whatsoever and doesn't provide further context without using that particular terminology that I could find. Perhaps it was removed at some point and this reference wasn't cleaned up?

adrolter avatar Dec 24 '23 05:12 adrolter

While it's hardly the "detailed" explanation implied, the note was added in 2007 with https://github.com/php/doc-en/commit/a3408906fa567a73cbf38ad56964984ec3e9a679 and I'm assuming was in reference to a warning on the arrays page:

As of PHP 4.3.0, the index generation behaviour described above has changed. Now, if you append to an array in which the current maximum key is negative, then the next key created will be zero (0). Before, the new index would have been set to the largest existing key + 1, the same as positive indices are.

So there's two parts to this:

  1. Does something need to be mentioned in the arrays page about the change between PHP 7 and 8? Would probably be nice, given that the upgrade guide only gives it a short one-line bullet point.
  2. Does something need to be mentioned in the array_fill page? Presumably meaning a link to the arrays page.

damianwadley avatar Dec 24 '23 07:12 damianwadley