Wayne Rooney has signed a four-year contract that will keep him at Manchester United until June 2019.