chriso/klein.php — pull request #183 by RafeKettler (2014-02-21 02:39:13+00:00)
Title: Fix tests that fail on HHVM due to inconsistencies with Zend on key()

https://github.com/facebook/hhvm/blob/master/hphp/doc/inconsistencies#L23

HHVM does not reset the internal array cursor when an array is copied. Zend 5.5
does, so when an array is passed to a function (like `$sample_data` in the fixed
tests) the internal cursor is reset. For 5.6 the maintainers have specified that
how the internal cursor is copied is an implementation detail and may change without
warning. So it's best to be explicit and not rely on `key()` or `current()` at all.

I just fixed the tests for which this causes problems on HHVM as part of the effort
to get klein.php to 100% for HHVM. See https://github.com/facebook/hhvm/issues/1767.