While there’s nothing official from Apple, 7+ years is a decent bet. That’s because:
-
Historically (and this is absolutely not guaranteed), Apple has provided iOS upgrades (new features) for a period of 6ish years, plus iOS security updates/fixes (no new features) for an additional 1-2ish years. See here: https://en.wikipedia.org/wiki/IPhone
-
By California law, Apple must be able to repair an iPhone for a period of seven (7) years. Note that this says nothing about the repair cost which could be $$$$$. It also applies to California only, although I expect Apple will do this over a larger area.
However, in order to last 7 or so years, maintenance such as battery replacements must be periodically done (and most people here seem to be allergic to that). Having Apple do the battery replacement is recommended as some random repair shop might not use the best batteries.
Huh? The message explains exactly what the problem is: if you use iCloud Photos, you cannot see the photos via a cable. Instead, turn on iCloud Photo sync on your Mac, and your photos will automatically (but a bit slowly) download to your Mac from iCloud (this assumes you are using the same Apple ID on both your Mac and iPhone, though).