#47330 [Csd]: key return value should be specified
| From: | torben@php.net | Date: | Thu, 27 Aug 2009 04:53:30 +0000 |
| Subject: | #47330 [Csd]: key return value should be specified | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-2672@lists.php.net to get a copy of this message | ||
ID: 47330
Updated by: torben@php.net
Reported By: thuejk at gmail dot com
Status: Closed
Bug Type: Documentation problem
Operating System: All
PHP Version: Irrelevant
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
I went ahead and documented this since it's been the behaviour since
the first commit of PHP 4 (PHP 3 had no NULL type).
Previous Comments:
------------------------------------------------------------------------
[2009-08-27 04:48:25] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=287789
Log: Document the fact that key() returns NULL when the array pointer
is out of bounds.
Addresses Bug #47330.
------------------------------------------------------------------------
[2009-08-26 16:31:40] torben@php.net
Yes, I should have said "defined as NULL" instead of "is NULL". You can
define it as NULL but it will be silently converted to the empty string.
------------------------------------------------------------------------
[2009-08-26 16:26:32] thuejk at gmail dot com
Ah, I misunderstood.
Null is not a possible array index, hence my confusion. Array indices
are always strings or ints. (as I found out when debugging a face of a
float being silently truncated to int when used as an array index...)
------------------------------------------------------------------------
[2009-08-26 16:20:34] torben@php.net
You're correct that key() does not return NULL if the array value is
NULL, but that's not what I said; I said "array index", not "array
value".
That said, I must apologize as I was also incorrect: key() does not in
fact return NULL if the array index is NULL; it returns the empty
string. That's what I get for posting when I should have gone to bed
instead.
Re-opening.
------------------------------------------------------------------------
[2009-08-26 08:58:00] thuejk at gmail dot com
>key() also returns NULL if the array index currently being examined
>contains NULL, and therefore gives no useful information as to
whether
>the end of the array has been passed or not.
And anyway, if theis is a case it is an even worse bug than my original
report, since the manual states
Return Values: Returns the index.
It specifically does NOT say anything about returning null if the array
value is null.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/47330
--
Edit this bug report at http://bugs.php.net/?id=47330&edit=1