A probabilistic approach to phase calibration - I. Effects of source structure on fringe-fitting