Good question, I think 4 years or so, after which they will not run modern apps so well.
However,in future when phones reach a performance level such that it is unnecessary to upgrade to run new apps, i'd expect 7 years. PC's for example reached this 'level' around 2009'ish. There is simply no need for most people to upgrade PC's these days unless you are a hardcore gamer or run niche applications. My old 2008 IBM T400 is perfectly capable of running word and playing videos and multitasking. Chucked in an SSD and you don't notice much difference between that and my modern desktop for most productivity applications.