Skip to content

Magento 2.4.7 Bootstrap Script Error PHP Fatal error: Uncaught TypeError: MagentoApplicationPerformanceMonitor

After upgrading from Magento Open Source 2.4.6 to 2.4.7 custom PHP scripts that Bootstrap Magento 2 are failing to run with the error

PHP Fatal error:  Uncaught TypeError: MagentoApplicationPerformanceMonitorPluginApplicationPerformanceMonitor::aroundLaunch(): Return value must be of type MagentoFrameworkAppResponseInterface, array returned in /var/www/dev/magento2/vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php:38

Bootstrap script is based on this example https://magento.stackexchange.com/a/76382/7863

public function launch()
    {
        $this->run();
        return $this->_response;
    }

If I dump $this->_response I get the correct output from my script, I need to return this as value of type MagentoFrameworkAppResponseInterface.