Closes ticket #3080 in CakePHP Lighthouse (http://cakephp.lighthouseapp.com/projects/42648/tickets/3080-hashflatten-endless-loop-on-single-0-int-keys).
Hash::flatten has a bug which causes an endless loop when try to flatten an integer key.
Probably the $data array pointer won't reset itself when doing:

$data = $element

and

list($data, $path) = array_pop($stack)

The solution is to reset the pointer after the assignments.
Add test for recursion issues in Hash::expand().

Refs #3080
Merge branch 'bbcrew-master'

From pull/1062 reset data arrays when expanding to solve
infinite recursion issues in PHP5.2

Fixes #3080