The policy does not mention unused code, because it is not treated differently.
All public interfaces to the MediaWiki core PHP code that was released, must follow the deprecation policy prior to removal.
Local variables are not public, and do not follow the deprecation policy as such.
There is no exemption for "unused code". There are multiple reasons for this, but for me the main one is that we can't really know whether something is unused.
Wikimedia Foundation has all its code public in our Gerrit, and with pretty good search. Although even with that search, we've definitely missed things in the past. It's not perfect. It's always better to deprecate first and allow ourselves to find warnings from production.
Apart from WMF, it's important to remember that MediaWiki is an open-source project used for many other websites. One would need to know every website in the world and every possible way to publish source code relating to MediaWiki, and search it. One would also need to know which version of all those projects are currently in deployment or not. This isn't realistic.
Besides public code, there is also site configuration which is usually not made public (Wikipedia represents the exception there, not the norm).