Question

Using Magento Cloud, the DI compile step keeps failing after upgrading from 2.3.3 to 2.3.5 via composer and pushing the changes up.

The error is the same every time I've tried, which is:

PHP Fatal error:  Declaration of Magento\PageBuilder\Model\Dom\NodeList::item($index) : ?Magento\PageBuilder\Model\Dom\Adapter\ElementInterface must be compatible with Magento\PageBuilder\Model\Dom\Adapter\NodeListInterface::item(int $index): ?Magento\PageBuilder\Model\Dom\Adapter\ElementInterface in /app/vendor/magento/module-page-builder/Model/Dom/NodeList.php on line 19

The only difference in declaration seems to be the "int" type declared for the $index parameter in the adapter interface. But both of the referenced files seem to exist in the same composer package (magento/module-page-builder) so I am a bit confused about how to solve it.

The version of module-page-builder that composer installed is 1.3.1.

Was it helpful?

Solution

The only difference in declaration seems to be the "int" type declared for the $index parameter

This is the main problem. Method declaration should be the same as in the interface

As I can see 1.3.1 is the latest version, so you can create a patch for fixing the issue in vendor modules.

add patch to composer.json

"extra": {
        "magento-force": "override",
        "enable-patching": true,
        "patches": 
            "magento/module-page-builder": {
                "Declaration fix": {
                    "1.3.1": "patches/PageBuilder/1.3.1/fix_revert.patch"
                }
            },

and create patch under patches/PageBuilder/1.3.1/fix_revert.patch by adding int into declaration and using git diff

OTHER TIPS

Please verify your PHP version. I encountered the same issue while on PHP 7.1. Switching to PHP 7.2 resolved this error.

Good luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top