[Fix] ArrayIterator::valid was incorrectpre-hhvm
commitcf9b612ed0f96e223f4479672bdbe6b2fded49f9
authorMark Williams <mwilliams@fb.com>
Thu, 12 Aug 2010 18:21:14 +0000 (12 11:21 -0700)
committermacvicar <macvicar@fb.com>
Wed, 7 Dec 2011 05:04:16 +0000 (6 21:04 -0800)
tree0ba09f2029f90d87bc3ae606f415eeff5aabe034
parent70aac1407e72faf5d1b7c91adbdce7faaf85ba87
[Fix] ArrayIterator::valid was incorrect

Summary:
ArrayIterator::valid was implemented as current() !== false, which would
incorrectly terminate when an element's value was false. Test key() !== null
instead (noting that keys cant be null).

Test Plan:
fast_tests, flib/type/dict

This is just a revert of a bogus change. Adding a new test case to prevent a
repeat.

<?php

function test($a) {
  $it = new ArrayIterator($a);
  while ($it->valid()) {
    var_dump($it->key());
    var_dump($it->current());
    $it->next();
  }
  }

test(array('a' => 'x',
           false => 'y',
           '1' => false,
           null => 'z',
           'c' => 'w'));

DiffCamp Revision: 144935
Reviewed By: hzhao
CC: hphp-diffs@lists, hzhao
Revert Plan:
OK
src/system/classes/iterator.php