How does the use of Singletons impact object-oriented programming in PHP?

Using Singletons in object-oriented programming in PHP can impact the flexibility and testability of the code. Singletons create global state which can make it harder to track dependencies and can lead to tight coupling between classes. To mitigate these issues, it's recommended to use dependency injection instead of Singletons.

class DatabaseConnection {
    private static $instance;

    private function __construct() {
        // private constructor to prevent instantiation
    }

    public static function getInstance() {
        if (!self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    // other database connection methods
}

// Usage
$database = DatabaseConnection::getInstance();