I'm working on a website coded in PHP and have been reading about Dependency Injection. However, I don't understand the reasoning against this kind of situation:
I have a script that currently has 2 global variables (one that's a DB connection, and one that stores the current user's data that's pulled from the DB). These 2 global variables are each used in all but one or two of my classes. The thought of implementing these global objects with DI sounds like a lot of extra typing for no real reward; up to 2 extra arguments to be passed to most of my classes along with up to 2 extra attributes to hold these injected dependencies.
I'm not asking this because I want an excuse to not have to redo the globals, I'm asking this because I really want to know:
If a small amount of objects are used by almost every object in your script, is it OK to make those objects global? What would be the benefit of using DI over globals in this case?