Fix leak in foreach with by-ref iteration of ref array
Simplify foreach flags

 * FE_RESET_VARIABLE and FE_RESET_REFERENCE were always set
   together.
 * In some places the code checked FE_FETCH_BYREF instead of
   FE_RESET_REFERENCE and relied on them having the same value.
 * Now the FE_RESET_* flags are dropped and everything uses
   FE_FETCH_BYREF