Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for php8.4 #3

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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