What are the potential pitfalls of using a DIC in PHP projects?

One potential pitfall of using a Dependency Injection Container (DIC) in PHP projects is that it can lead to overly complex and difficult-to-maintain code if not used properly. To avoid this, it is important to carefully design the container configuration and avoid excessive nesting of dependencies.

// Example of properly configuring a DIC in PHP
$container = new Container();

// Registering dependencies
$container->add('database', function() {
    return new Database();
});

$container->add('userRepository', function($container) {
    return new UserRepository($container->get('database'));
});

// Resolving dependencies
$userRepository = $container->get('userRepository');