Looking into this more, it turns out some of the PHP snippet scopes were improved in 20091010, but not all of them - foreach was one of the ones that was missed. I'll update them all for the next beta.