Apple doesn't provide any way to transfer music purchased on CD directly from one iPhone to another.
Their model is that you import that music into a master iTunes/Music library on a Mac or PC, and then manually synchronize mobile devices (iPods, iPhones, iPads) against that library. You safeguard the master library on the computer, and to "transfer" music to a new mobile device, you plug that device into your computer, and then do another manual synchronization.
Sync music between your Mac and iPhone, iPad, or iPod touch - Apple Support
If you have purchased music from the iTunes Store, you can probably re-download it.
If you subscribe to iTunes Match, or if you subscribe to Apple Music and use the "Sync Library" feature, things might operate a bit differently.