From 2b796db811945f7f9e77e7fb7520b920a77b36d8 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 25 Sep 2024 15:32:52 +0200 Subject: [PATCH] fix for php8.4 --- phpstan-bootstrap-mage-autoload.php | 7 ++++--- phpstan-bootstrap.php | 8 ++++---- src/Autoload/Magento/ModuleControllerAutoloader.php | 2 +- src/Config/MagentoCore.php | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/phpstan-bootstrap-mage-autoload.php b/phpstan-bootstrap-mage-autoload.php index f0b7fec..92d29f0 100644 --- a/phpstan-bootstrap-mage-autoload.php +++ b/phpstan-bootstrap-mage-autoload.php @@ -1,10 +1,11 @@ getParameter('magentoRootPath'); if (empty($magentoRootPath)) { @@ -23,11 +24,11 @@ * We replace the original Varien_Autoload autoloader with a custom one in order to prevent errors with invalid classes * that are used throughout the Magento core code. * The original autoloader would in this case return false and lead to an error in phpstan because the type alias in extension.neon - * is evaluated afterwards. + * is evaluated afterward. * * @see \Varien_Autoload::autoload() */ -spl_autoload_register(static function($className) { +spl_autoload_register(static function ($className) { spl_autoload_unregister([Varien_Autoload::instance(), 'autoload']); $classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $className))); diff --git a/phpstan-bootstrap.php b/phpstan-bootstrap.php index 3b04ca3..1865ce6 100644 --- a/phpstan-bootstrap.php +++ b/phpstan-bootstrap.php @@ -1,10 +1,11 @@ getParameter('magentoRootPath'); if (empty($magentoRootPath)) { @@ -35,7 +36,7 @@ $appPath = implode(PS, $paths); set_include_path($appPath . PS . get_include_path()); -include_once "Mage/Core/functions.php"; +include_once 'Mage/Core/functions.php'; (new ModuleControllerAutoloader('local'))->register(); (new ModuleControllerAutoloader('core'))->register(); @@ -46,8 +47,7 @@ * Autoloading is needed only for the PHPStanMagento1\Config\MagentoCore which inherits from some magento classes. * PHPStan uses static analysis, so doesn't require autoloading. */ -spl_autoload_register(static function($className) { - +spl_autoload_register(static function ($className) { $classFile = str_replace(' ', DIRECTORY_SEPARATOR, ucwords(str_replace('_', ' ', $className))); $classFile .= '.php'; diff --git a/src/Autoload/Magento/ModuleControllerAutoloader.php b/src/Autoload/Magento/ModuleControllerAutoloader.php index f4601c8..1de7c84 100644 --- a/src/Autoload/Magento/ModuleControllerAutoloader.php +++ b/src/Autoload/Magento/ModuleControllerAutoloader.php @@ -15,7 +15,7 @@ final class ModuleControllerAutoloader /** @var string */ private $codePool; - public function __construct(string $codePool, string $magentoRoot = null) + public function __construct(string $codePool, ?string $magentoRoot = null) { if (empty($magentoRoot)) { $magentoRoot = BP; diff --git a/src/Config/MagentoCore.php b/src/Config/MagentoCore.php index d24cc30..62495a7 100644 --- a/src/Config/MagentoCore.php +++ b/src/Config/MagentoCore.php @@ -531,7 +531,7 @@ protected function _getDeclaredModuleFiles() */ protected function _makeEventsLowerCase($area, \Varien_Simplexml_Config $mergeModel) { - $events = $mergeModel->getNode($area . "/" . \Mage_Core_Model_App_Area::PART_EVENTS); + $events = $mergeModel->getNode($area . '/' . \Mage_Core_Model_App_Area::PART_EVENTS); if ($events !== false) { $children = clone $events->children(); /** @var \Mage_Core_Model_Config_Element $event */