Some people say, "You don't need to use dependency injection for everything. Sometimes dependency injection is not the best choice."

It occurs to me that the people who say this are the ones who can't use it for everything. They say "choose what's best for your situation", but their situation precludes the use of dependency injection in the first place.

Anyone who says "X is not always the best choice", but does not have X as an available option, is being disingenuous. They are not choosing against X based on an examination of the tradeoffs involved. Instead, they are making a virtue out of necessity, then posing as virtuous for not having better choices available.

Dependency injection is, by default and until proven otherwise, the best choice -- when you have that choice available to you.

If that choice is not available to you, if you cannot construct an object using any form of dependency injection (constructor injection, setter injection, etc.), then you need to consider if the code in question has been designed poorly.

Are you stuck with a legacy PHP application? You should buy my book because it gives you a step-by-step guide to improving you codebase, all while keeping it running the whole time.