An iOS device is truly erased locally when you hit the erase button, because all flash memory access is marshalled through hardware requiring an encryption ID.
As has been previously noted, the iPhone operation "Erase All Content and Settings" does not actually overwrite existing information stored on the device, but simply destroys the encryption keys and thereby prevents access. In theory, this should be adequate to protect the privacy of a user’s on-device information – assuming that Apple has implemented the "erase" process flawlessly.
To guard against the (improbable) case in which "erase" process does not function properly, I personally spend a few minutes to overwrite the iPhone storage before disposing of the device.
- Disable Find My (Settings | [Apple ID] | Find My).
- Sign out of the Apple ID (Settings | [Apple ID], scroll down and tap Sign Out).
- Erase content (Settings | General | Transfer or Reset iPhone | Erase All Content and Settings).
- Setup the iPhone as a new device in a minimal configuration state by completing the setup wizard, skipping steps in which personally identifiable information is requested (e.g., Face ID, Apple ID, WiFi/cellular connection, location services, etc.). At this point, the iPhone will only contain the default iOS system files and apps (about 10GB).
- On a PC/Mac, create a set of data files containing random bytes through a programming script (or obtain from a source such as here).
- Using iMazing, copy the random data files to the iPhone (see here) in order to overwrite the unused storage space. A notification “iPhone Storage Full” will appear when all free space has been overwritten.
- Erase content again (Settings | General | Transfer or Reset iPhone | Erase All Content and Settings).