fix for PHP version smaller that 5.4

closure requires special handling for passing the context this