Replaced instanceof with type attribute for ZF2 compatibility