Local electronic and crystal structure of rare-earth cobalt phosphides RCo2P2 (R = La, Ce, Pr, Nd, Eu) studied by XAFS and RIXS