Edit report at https://bugs.php.net/bug.php?id=62073&edit=1
ID: 62073 Updated by: fel...@php.net Reported by: mr_platelet+jin6vr at fastmail dot fm Summary: different ways of iterating over an SplMaxHeap result in different keys -Status: Open +Status: Assigned Type: Bug Package: SPL related Operating System: Debian Linux 6.0.4 PHP Version: 5.3.13 -Assigned To: +Assigned To: colder Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2012-05-19 16:50:20] mr_platelet+jin6vr at fastmail dot fm Description: ------------ If I use a foreach-loop to iterate over an SplMaxHeap, the first key is 1. If I use the "key" method, the first key is 0. Just in case it's relevant, this is the "configure" command I used to compile PHP. (Don't be misled by the value for "prefix"; I'm using PHP 5.3.13, not PHP 5.3.12.) ./configure --prefix=/usr/local/php/5.3.12 --disable-cgi --with- pgsql=shared,/usr --with-xmlrpc=shared --with-tidy=shared,/usr --with- mssql=shared,/usr --with-sqlite=shared,/usr --with-snmp=shared,/usr --with- xsl=shared,/usr --with-recode=shared,/usr --with-unixODBC=shared,/usr --with- pspell=shared,/usr --with-mysqli=shared,/usr/bin/mysql_config --with- mysql=shared,/usr --with-mcrypt=shared,/usr --with-ldap-sasl=/usr --with- ldap=shared,/usr --with-t1lib=shared,/usr --with-ttf=shared,/usr --enable- intl=shared --with-pdo-firebird=shared,/usr --with-interbase=shared,/usr --with- imap-ssl --with-freetype-dir=shared,/usr --with-png-dir=shared,/usr --with-xpm- dir=shared,/usr/X11R6 --with-jpeg-dir=shared,/usr --with-gmp=shared,/usr -- enable-gd-native-ttf --with-gd=shared,/usr --with-zlib-dir=/usr --with- enchant=shared,/usr --with-curl=shared,/usr --without-mm --with-mhash=yes -- enable-zip --enable-soap --with-openssl=/usr --with-kerberos=/usr --with-zlib -- with-libxml-dir=/usr --enable-wddx --enable-sockets --enable-shmop --with-pcre- regex=/usr --with-onig=/usr --enable-mbstring --with-gettext --enable-ftp -- enable-exif --with-iconv --without-gdbm --with-db4 --enable-ctype --with-bz2 -- enable-bcmath --enable-sysvmsg --enable-sysvshm --enable-sysvsem --enable- calendar --with-pic --disable-static --disable-rpath --with-regex=php --disable- debug --enable-pcntl --with-readline Test script: --------------- <?php $heap = new SplMaxHeap; $heap->insert(42); foreach ($heap as $key => $value) { break; } var_dump($key); var_dump($value); $heap = new SplMaxHeap; $heap->insert(42); var_dump($heap->key()); var_dump($heap->current()); Expected result: ---------------- I expect to see 4 lines of output from the script, and, among other things, I expect the third line to be the same as the first line. Actual result: -------------- The script gives this output: int(1) int(42) int(0) int(42) Note that the third line differs from the first. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62073&edit=1