Skip to content

Commit

Permalink
fix for php8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel authored and tmotyl committed Oct 10, 2024
1 parent 348ab68 commit 2b796db
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions phpstan-bootstrap-mage-autoload.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types=1);

use PHPStanMagento1\Autoload\Magento\ModuleControllerAutoloader;

/**
* @var $container \PHPStan\DependencyInjection\MemoizingContainer
* @var \PHPStan\DependencyInjection\MemoizingContainer $container
*/
$magentoRootPath = $container->getParameter('magentoRootPath');
if (empty($magentoRootPath)) {
Expand All @@ -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)));
Expand Down
8 changes: 4 additions & 4 deletions phpstan-bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php

declare(strict_types=1);

use PHPStanMagento1\Autoload\Magento\ModuleControllerAutoloader;

/**
* @var $container \PHPStan\DependencyInjection\MemoizingContainer
* @var \PHPStan\DependencyInjection\MemoizingContainer $container
*/
$magentoRootPath = $container->getParameter('magentoRootPath');
if (empty($magentoRootPath)) {
Expand Down Expand Up @@ -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();
Expand All @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/Autoload/Magento/ModuleControllerAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Config/MagentoCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 2b796db

Please sign in to comment.