Is it advisable to use static classes as containers for frequently used objects in PHP applications?

Using static classes as containers for frequently used objects in PHP applications can be a convenient way to access these objects without the need for instantiation. However, it can lead to tight coupling and make the code harder to test and maintain. It's generally better to use dependency injection or a service container to manage and retrieve these objects.

class Container {
    private static $objects = [];

    public static function set($key, $object) {
        self::$objects[$key] = $object;
    }

    public static function get($key) {
        return self::$objects[$key];
    }
}

// Usage example
Container::set('db', new DatabaseConnection());
$db = Container::get('db');