Quantum phase-gate operation based on nonlinear optics: full quantum analysis