Unexpected four-membered over six-membered ring formation during the synthesis of azaheterocyclic phosphonates: experimental and theoretical evaluation.