[ticket/12710] Fix foreach generation

PHPBB3-12710
[ticket/12710] d

PHPBB3-12710