In bug 381123 KDevelop crashed on certain PHP code. The underlying cause seems to that the classDec does not have an internalContext() set (no clue why, I couldn't figure that out).
This diff fixes the crash, but does not yield the desired behaviour: automatically deriving the type of the foreach variable (i.e. in the example of the test plan: the $row variable should be an int, but is currently calculated as mixed. Placing the foreach after the class definition works, though).