use mode delegates in PHP

fixes #2197