Description
Summary (*)
Magento 2.4.4 running on PHP 8.1
If you create a plugin for any method of class vendor/magento/module-backend/Model/Menu.php
then you will receive below error in admin panel
Error: Call to undefined method ReflectionUnionType::getName() in /magento244/vendor/magento/framework/Code/Generator/EntityAbstract.php:335
Stack trace:
#0 /magento244/vendor/magento/framework/Code/Generator/EntityAbstract.php(393): Magento\Framework\Code\Generator\EntityAbstract->extractParameterType(Object(ReflectionParameter))
#1 [internal function]: Magento\Framework\Code\Generator\EntityAbstract->_getMethodParameterInfo(Object(ReflectionParameter))
#2 /magento244/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(103): array_map(Array, Array)
#3 /magento244/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(76): Magento\Framework\Interception\Code\Generator\Interceptor->_getMethodInfo(Object(ReflectionMethod))
#4 /magento244/vendor/magento/framework/Code/Generator/EntityAbstract.php(226): Magento\Framework\Interception\Code\Generator\Interceptor->_getClassMethods()
#5 /magento244/vendor/magento/framework/Interception/Code/Generator/Interceptor.php(177): Magento\Framework\Code\Generator\EntityAbstract->_generateCode()
#6 /magento244/vendor/magento/framework/Code/Generator/EntityAbstract.php(106): Magento\Framework\Interception\Code\Generator\Interceptor->_generateCode()
#7 /magento244/vendor/magento/framework/Code/Generator.php(130): Magento\Framework\Code\Generator\EntityAbstract->generate()
#8 /magento244/vendor/magento/framework/Code/Generator/Autoloader.php(53): Magento\Framework\Code\Generator->generateClass('Magento\\Backend...')
#9 [internal function]: Magento\Framework\Code\Generator\Autoloader->load('Magento\\Backend...')
#10 /magento244/vendor/magento/framework/Code/Reader/ClassReader.php(34): ReflectionClass->__construct('Magento\\Backend...')
#11 /magento244/vendor/magento/framework/ObjectManager/Definition/Runtime.php(54): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\\Backend...')
#12 /magento244/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(48): Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Magento\\Backend...')
#13 /magento244/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Backend...', Array)
#14 /magento244/generated/code/Magento/Backend/Model/MenuFactory.php(43): Magento\Framework\ObjectManager\ObjectManager->create('\\Magento\\Backen...', Array)
#15 /magento244/vendor/magento/module-backend/Model/Menu/Config.php(140): Magento\Backend\Model\MenuFactory->create()
#16 /magento244/vendor/magento/module-backend/Model/Menu/Config.php(116): Magento\Backend\Model\Menu\Config->_initMenu()
#17 /magento244/vendor/magento/module-backend/Block/Menu.php(265): Magento\Backend\Model\Menu\Config->getMenu()
#18 /magento244/generated/code/Magento/Backend/Block/Menu/Interceptor.php(41): Magento\Backend\Block\Menu->getMenuModel()
#19 /magento244/vendor/magento/module-backend/Model/View/Result/Page.php(28): Magento\Backend\Block\Menu\Interceptor->getMenuModel()
#20 /magento244/generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php(23): Magento\Backend\Model\View\Result\Page->setActiveMenu('Magento_Backend...')
Examples (*)
Install module https://github.com/redchamps/magento2-module-backend-menu-plugin using below command to quickly repeat the problem
composer require redchamps/magento2-module-backend-menu-plugin
Proposed solution
The issue occurs to to function exchangeArray called in class \Magento\Backend\Model\Menu this method belongs to parent class \ArrayObject and has return type object|array
& the Magento code doesn;t support the mix return type while creating Intercepter for the class.
This issue occurs only when the Intercepter class being created for \Magento\Backend\Model\Menu & in native Magento there is no plugin for this class so this error appears only when some third-party plugin or customisation do this.
This will be the case throughout the Magento classes not only for \Magento\Backend\Model\Menu.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status