For your particular site possibly an interesting approach would be to run all “text chunks” pasted in via 4-5 regexes. For PHPs case you could quite easily come up with a few regexes that would be very accurate at predicting that a chunk pasted in is PHP. Then the editor could auto wrap. This would not have any performance impact, but hooking it in would be a bit tricky.
A more general approach as proposed by @tDo may be a bit harder to come up with. Clearly if we ever shipped something like this it would have to be opt in.