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.

2 Answers 2


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,
            "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

  • Thanks, that's a good idea! I will just patch it for now.
    – Ben
    Commented May 21, 2020 at 20:39
  • 1
    This worked! For the record, I needed to cd vendor/magento/module-page-builder, run git init to create a blank repo for the module, commit the original code, make my fix, and then I could use git diff to create the patch file. I then deleted my new .git directory to clean up, and applied the patch with composer.
    – Ben
    Commented May 22, 2020 at 5:24
  • I am facing the same issue can you please simplify how to use it? Commented Sep 18, 2020 at 9:00

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.