Ermakov–Ray–Reid systems in nonlinear optics