4

I got this error, i do not know how to fix this. Can anybody explain to me why cause this and how can i fix this?

TypeError: get_parent_class(): Argument #1 ($object_or_class) must be an object or a valid class name, string given in /var/www/html/rakuten_magento/vendor/magento/framework/Code/Reader/ClassReader.php:98
Stack trace:
#0 /var/www/html/rakuten_magento/vendor/magento/framework/Code/Reader/ClassReader.php(98): get_parent_class()
#1 /var/www/html/rakuten_magento/vendor/magento/framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php(142): Magento\Framework\Code\Reader\ClassReader->getParents()
#2 /var/www/html/rakuten_magento/vendor/magento/framework/View/Element/UiComponent/Argument/Interpreter/ConfigurableObject.php(120): Magento\Framework\View\Element\UiComponent\Argument\Interpreter\ConfigurableObject->getParents()
#3 /var/www/html/rakuten_magento/generated/code/Magento/Framework/Data/Argument/InterpreterInterface/Proxy.php(95): Magento\Framework\View\Element\UiComponent\Argument\Interpreter\ConfigurableObject->evaluate()
#4 /var/www/html/rakuten_magento/vendor/magento/framework/Data/Argument/Interpreter/Composite.php(61): Magento\Framework\Data\Argument\InterpreterInterface\Proxy->evaluate()
#5 /var/www/html/rakuten_magento/vendor/magento/module-ui/Config/Data.php(164): Magento\Framework\Data\Argument\Interpreter\Composite->evaluate()
#6 /var/www/html/rakuten_magento/vendor/magento/module-ui/Config/Data.php(167): Magento\Ui\Config\Data->evaluateComponentArguments()
#7 /var/www/html/rakuten_magento/vendor/magento/module-ui/Config/Data.php(167): Magento\Ui\Config\Data->evaluateComponentArguments()
#8 /var/www/html/rakuten_magento/vendor/magento/module-ui/Config/Data.php(167): Magento\Ui\Config\Data->evaluateComponentArguments()
#9 /var/www/html/rakuten_magento/vendor/magento/module-ui/Config/Data.php(111): Magento\Ui\Config\Data->evaluateComponentArguments()
#10 /var/www/html/rakuten_magento/vendor/magento/module-ui/Config/Data.php(136): Magento\Ui\Config\Data->initData()
#11 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/Reader/UiComponent.php(100): Magento\Ui\Config\Data->get()
#12 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/ReaderPool.php(105): Magento\Framework\View\Layout\Reader\UiComponent->interpret()
#13 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/Reader/Container.php(84): Magento\Framework\View\Layout\ReaderPool->interpret()
#14 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/ReaderPool.php(105): Magento\Framework\View\Layout\Reader\Container->interpret()
#15 /var/www/html/rakuten_magento/vendor/magento/framework/View/Page/Config/Reader/Body.php(68): Magento\Framework\View\Layout\ReaderPool->interpret()
#16 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/ReaderPool.php(105): Magento\Framework\View\Page\Config\Reader\Body->interpret()
#17 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout.php(346): Magento\Framework\View\Layout\ReaderPool->interpret()
#18 /var/www/html/rakuten_magento/generated/code/Magento/Framework/View/Layout/Interceptor.php(32): Magento\Framework\View\Layout->generateElements()
#19 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#20 /var/www/html/rakuten_magento/vendor/magento/framework/View/Page/Builder.php(65): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#21 /var/www/html/rakuten_magento/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#22 /var/www/html/rakuten_magento/vendor/magento/framework/View/Page/Config.php(227): Magento\Framework\View\Layout\Builder->build()
#23 /var/www/html/rakuten_magento/vendor/magento/framework/View/Page/Config.php(250): Magento\Framework\View\Page\Config->build()
#24 /var/www/html/rakuten_magento/app/code/Rakuten/MemberCard/Controller/Adminhtml/Card/Import.php(21): Magento\Framework\View\Page\Config->getTitle()
#25 /var/www/html/rakuten_magento/vendor/magento/framework/App/Action/Action.php(111): Rakuten\MemberCard\Controller\Adminhtml\Card\Import->execute()
#26 /var/www/html/rakuten_magento/vendor/magento/module-backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch()
#27 /var/www/html/rakuten_magento/vendor/magento/framework/App/FrontController.php(245): Magento\Backend\App\AbstractAction->dispatch()
#28 /var/www/html/rakuten_magento/vendor/magento/framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse()
#29 /var/www/html/rakuten_magento/vendor/magento/framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest()
#30 /var/www/html/rakuten_magento/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch()
#31 /var/www/html/rakuten_magento/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent()
#32 /var/www/html/rakuten_magento/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}()
#33 /var/www/html/rakuten_magento/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins()
#34 /var/www/html/rakuten_magento/vendor/magento/framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch()
#35 /var/www/html/rakuten_magento/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()
#36 /var/www/html/rakuten_magento/pub/index.php(30): Magento\Framework\App\Bootstrap->run()
#37 {main}

3 Answers 3

4

Sticking an echo in /vendor/magento/framework/Code/Reader/ClassReader.php helps

public function getMethodList($type)
    {
        $methods = [];
        echo $type . "\n";
        $allMethods = get_class_methods($type);

Run setup:di:compile see what's causing the issue

2

in my case, the problem was that the class path was incorrectly specified.Go to your ui_component file and in < dataSource > check < argument name="class" >This should be the class path!< /argument> I corrected it to the correct one and it worked for me. If this helped you - let me know

0

You can find the error class at the following file path.

vendor/magento/framework/Code/Reader/ClassReader.php

Please update the getParents() method in the file.

public function getParents($className)
{
    if (isset($this->parentsCache[$className])) {
        return $this->parentsCache[$className];
    }

    echo $className . "\n"; // custom code to show class name

    $parentClass = get_parent_class($className);
    if ($parentClass) {
        $result = [];
        $interfaces = class_implements($className);
        if ($interfaces) {
            $parentInterfaces = class_implements($parentClass);
            if ($parentInterfaces) {
                $result = array_values(array_diff($interfaces, $parentInterfaces));
            } else {
                $result = array_values($interfaces);
            }
        }
        array_unshift($result, $parentClass);
    } else {
        $result = array_values(class_implements($className));
        if ($result) {
            array_unshift($result, null);
        } else {
            $result = [];
        }
    }

    $this->parentsCache[$className] = $result;

    return $result;
}

Please run setup:di:compile to regenerate classes because sometimes classes are not properly generated. If the command shows an error, you will get more information about the error.

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.