php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51177 Iterator::key() return value should not say "integer 0 on failure"
Submitted: 2010-03-01 22:06 UTC Modified: 2010-03-06 14:31 UTC
From: david dot h at highgearmedia dot com Assigned: degeberg (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.2RC3 OS: n/a
Private report: No CVE-ID: None
 [2010-03-01 22:06 UTC] david dot h at highgearmedia dot com
Description:
------------
The documentation for the return value of Iterator::key() states that it will be integer 0 on failure.

1. The docs also state that an E_WARNING will be issued. This is probably the only correct response.
2. Integer 0 is a valid key for an iterator so it should not be used as an error signal value.

Test script:
---------------
<?php

$x = array();
$x[] = 'zero';
$x[] = 'one';
$obj = new ArrayObject($x);
$iter = $obj->getIterator();

echo $iter->key() . PHP_EOL;
echo $iter->current() . PHP_EOL;

?>


Expected result:
----------------
0
zero


Actual result:
--------------
0
zero

[Correct output, but it doesn't match the docs since key() is not returning an error but it is returning 0.]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-06 14:31 UTC] degeberg@php.net
Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=295890
Log: Fixed PHP bug #51177 (Iterator::key() return value should not say &quot;integer 0 on failure&quot;)
 [2010-03-06 14:31 UTC] degeberg@php.net
-Status: Open +Status: Closed
 [2010-03-06 14:31 UTC] degeberg@php.net
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.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 15:01:33 2025 UTC