Skip to content

PHP Fatal error: Cannot use ::class with dynamic class name in ../vendor/laminas/laminas-servicemanager/src/ServiceManager.php on line 984

i use Magento 2.4.3 with php7.4 after composer update:

  - Updating laminas/laminas-dependency-plugin (2.4.0 => 2.5.0):  Checking out 8f2d101993
  - Updating laminas/laminas-stdlib (3.13.0 => 3.16.1):  Checking out f4f7736418
  - Updating laminas/laminas-servicemanager (3.17.0 => 3.20.0):  Checking out bc2c2cbe2d
  - Updating laminas/laminas-validator (2.25.0 => 2.29.0):  Checking out e40ee8d86c
  - Updating laminas/laminas-mime (2.10.0 => 2.11.0):  Checking out 60ec04b755
  - Updating laminas/laminas-mail (2.16.0 => 2.21.1):  Checking out 6e3d32a81d
  - Updating laminas/laminas-eventmanager (3.5.0 => 3.9.2):  Checking out 55f7c337f4
  - Updating laminas/laminas-config (3.7.0 => 3.8.0):  Checking out 46baad58d0
  - Updating laminas/laminas-modulemanager (2.12.0 => 2.14.0):  Checking out fb0a2c3442
  - Updating laminas/laminas-serializer (2.13.0 => 2.14.0):  Checking out c4ceeb080f
  - Updating laminas/laminas-text (2.9.0 => 2.10.0):  Checking out 40f7acdb28

I got this error message:

PHP Fatal error:  Cannot use ::class with dynamic class name in ../vendor/laminas/laminas-servicemanager/src/ServiceManager.php on line 984

enter image description here

            while (isset($this->aliases[$tCursor])) {
            $stack[] = $aCursor;
            if ($aCursor === $this->aliases[$tCursor]) {
                throw CyclicAliasException::fromCyclicAlias($alias, $this->aliases);
            }
            $aCursor = $tCursor;
            $tCursor = $this->aliases[$tCursor];
        }

enter image description here

            throw new ServiceNotCreatedException(sprintf(
            'A non-callable delegator, "%s", was provided; expected a callable or instance of "%s"',
            is_object($delegatorFactory) ? $delegatorFactory::class : gettype($delegatorFactory),
            DelegatorFactoryInterface::class
        ));
    }
}

my composer.json

{
  "name": "magento/project-community-edition",
  "description": "eCommerce Platform for Growth (Community Edition)",
  "type": "project",
  "license": [
    "OSL-3.0",
    "AFL-3.0"
  ],
  "require": {
    "php": "^7.3.0||^7.4.0",

    "immerce/email": "*",
    "laminas/laminas-config": "*",
    "laminas/laminas-dependency-plugin": "*",
    "laminas/laminas-eventmanager": "*",
    "laminas/laminas-mail": "*",
    "laminas/laminas-mime": "*",
    "laminas/laminas-modulemanager": "*",
    "laminas/laminas-serializer": "*",
    "laminas/laminas-servicemanager": "*",
    "laminas/laminas-stdlib": "*",
    "laminas/laminas-validator": "*",
    "liquid/liquid": "^1.4.17",
 
    "psr/cache": "2.0.0",
    "psr/simple-cache": "^1.0",
    "sendinblue/module-sendinblue": "*",
    "symfony/polyfill-mbstring": "*",
    "vertex/module-tax": "4.2.*",
    "vertex/product-magento-module": "4.2.1",
    "vertexinc/product-magento-module": "4.2.1",
    "wallee/magento-2": "1.3.14"
  },
  "require-dev": {
    "allure-framework/allure-phpunit": "~1.2.0",
    "friendsofphp/php-cs-fixer": "~2.14.0",
    "lusitanian/oauth": "~0.8.10",
    "magento/magento-coding-standard": "~3.0.0",
    "magento/magento2-functional-testing-framework": "2.4.5",
    "mockery/mockery": "^1.2",
    "pdepend/pdepend": "2.5.2",
    "phpmd/phpmd": "@stable",
    "sebastian/phpcpd": "~3.0.0",
    "squizlabs/php_codesniffer": "~3.4.0"
  },
  "config": {
    "preferred-install": "source",
    "sort-packages": true,
    "use-include-path": true,
    "discard-changes": true,
    "allow-plugins": {
      "laminas/laminas-dependency-plugin": true,
      "magento/magento-composer-installer": true,
      "magento/inventory-composer-installer": true,
      "cweagans/composer-patches": true

What can i do to fix it?
Thank for any help.
Best regards

After update the composer file:

    staging@***:~/public_html(develop)$ php bin/magento maintenance:enable && php bin/magento setup:upgrade && rm -rf var/view_preprocessed var/cache/ var/page_cache/ var/generation/* && php bin/magento setup:di:compile && php bin/magento setup:static-content:de en_US de_CH fr_CH -f && php bin/magento cache:enable && php bin/magento cache:flush && php bin/magento maintenance:disable

Argument 1 passed to LaminasDiConfig::ensureArrayOrArrayAccess() must be an instance of LaminasDimixed, array given, called in /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Config.php on line 104#0 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Config.php(104): LaminasDiConfig->ensureArrayOrArrayAccess()
#1 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/ConfigFactory.php(56): LaminasDiConfig->__construct()
#2 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/ConfigFactory.php(64): LaminasDiContainerConfigFactory->create()
#3 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(615): LaminasDiContainerConfigFactory->__invoke()
#4 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(234): LaminasServiceManagerServiceManager->doCreate()
#5 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/InjectorFactory.php(20): LaminasServiceManagerServiceManager->get()
#6 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/InjectorFactory.php(36): LaminasDiContainerInjectorFactory->createConfig()
#7 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/InjectorFactory.php(45): LaminasDiContainerInjectorFactory->create()
#8 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(615): LaminasDiContainerInjectorFactory->__invoke()
#9 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(234): LaminasServiceManagerServiceManager->doCreate()
#10 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/AutowireFactory.php(24): LaminasServiceManagerServiceManager->get()
#11 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/AutowireFactory.php(48): LaminasDiContainerAutowireFactory->getInjector()
#12 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-di/src/Container/ServiceManager/AutowireFactory.php(33): LaminasDiContainerAutowireFactory->canCreate()
#13 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(554): LaminasDiContainerServiceManagerAutowireFactory->canCreate()
#14 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(614): LaminasServiceManagerServiceManager->getFactory()
#15 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(234): LaminasServiceManagerServiceManager->doCreate()
#16 /var/www/***/repo/htdocs/magento/src/vendor/laminas/laminas-mvc/src/Application.php(147): LaminasServiceManagerServiceManager->get()
#17 /var/www/***/repo/htdocs/magento/src/setup/src/Magento/Setup/Application.php(51): LaminasMvcApplication->bootstrap()
#18 /var/www/***/repo/htdocs/magento/src/vendor/magento/framework/Console/Cli.php(80): MagentoSetupApplication->bootstrap()
#19 /var/www/***/repo/htdocs/magento/src/bin/magento(22): MagentoFrameworkConsoleCli->__construct()
#20 {main}