What are some potential pitfalls of using annotations for Dependency Injection in PHP?

Potential pitfalls of using annotations for Dependency Injection in PHP include tight coupling of classes to the DI container, decreased readability of code due to scattered annotations, and difficulty in refactoring due to reliance on annotations. To mitigate these issues, consider using constructor injection or setter injection instead of annotations.

// Constructor Injection
class SomeClass {
    private $dependency;

    public function __construct(Dependency $dependency) {
        $this->dependency = $dependency;
    }
}

// Setter Injection
class SomeOtherClass {
    private $dependency;

    public function setDependency(Dependency $dependency) {
        $this->dependency = $dependency;
    }
}