Phosphorus–carbon nanocomposite anodes for lithium-ion and sodium-ion batteries