Skip to content

Compatibility issue with PHP 8.4 and Magento 2.4.8 #680

@naseeraslam

Description

@naseeraslam

Describe the bug

When compiling the Magento codebase using bin/magento setup:di:compile, multiple deprecation warnings are triggered due to PHP 8.4's and magento 2.4.8 stricter type enforcement. Specifically, the Magefan Blog module contains constructors with parameters that are implicitly nullable but not explicitly marked as nullable, which is deprecated in PHP 8.4.

Preconditions:

  • Magento Version: 2.4.8
  • Magefan Blog Module Version: 2.12.4
  • PHP Version: 8.4

To Reproduce

Steps to reproduce the behavior:

  1. Install Magento 2.4.8 with PHP 8.4

  2. Install Magefan Blog module version 2.12.4

  3. Run the following command:

php bin/magento setup:di:compile

4. Observe the deprecation warnings during compilation.

---

### **Expected behavior**

Magento compilation should complete without deprecated functionality warnings. Constructors should explicitly define nullable parameters using `?Type`.

---

### **Actual behavior**

Compilation results in deprecated warnings like the following:

```bash
Deprecated Functionality: Magefan\Blog\Controller\Router::__construct(): Implicitly marking parameter $urlResolver as nullable is deprecated, the explicit nullable type must be used instead in /var/www/html/vendor/magefan/module-blog/Controller/Router.php on line 116

This issue is repeated across multiple files where constructor parameters are defaulted to null but are not explicitly marked as nullable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions