PHP avoid static classes to avoid dependencies, but I need to use global everywhere
问题 Many times I heard to avoid static classes because they will insert dependencies that will render your code unusable in other projects, and will not allow to unit test it. Let's say we have a typical class DB to access the Data Base, if such class is static we could call it wherever in our code: DB::execQuery(...); but this creates dependencies, so let's make the DB class NOT static, in such case we would have somewhere in our code: $db = new DB(); and then we could call in our code $db-