What is the best practice for injecting View Helper into the View Object in PHP?

When injecting a View Helper into a View Object in PHP, the best practice is to use dependency injection to pass the View Helper instance into the View Object's constructor. This allows for better decoupling of the View Object from the View Helper and makes the code more testable and maintainable.

class View {
    private $helper;

    public function __construct(ViewHelper $helper) {
        $this->helper = $helper;
    }

    public function render() {
        // Use the helper instance to render the view
        $this->helper->render();
    }
}

class ViewHelper {
    public function render() {
        // Render the view helper logic
    }
}

// Instantiate View Helper
$helper = new ViewHelper();

// Instantiate View and inject View Helper
$view = new View($helper);

// Render the view
$view->render();