Magento2 di:compile Error – Dependency Injection Code Generation Fix

code generationdependency-injectionerrormagento2

After successfully installed Magento2-stable version, when I try to run php bin/magento di:compile, It gives me below error

Interception cache generation... 6/7 [========================>---]  85% 1 hr 566.0 MiBErrors during compilation:

        WrongArgumentsOrder
                Incompatible argument type: Required type: \stdClass. Actual type: \ClassExtendsDefaultPhpType; File: vendor/magento/framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php

        ArgumentsOnSeparateLines
                Incompatible argument type: Required type: \stdClass. Actual type: \ClassExtendsDefaultPhpType; File: vendor/magento/framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php

        ClassArgumentAlreadyInjectedIntoContext
                Incorrect dependency in class ClassArgumentAlreadyInjectedIntoContext in E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

\ClassA already exists in context object

        ClassArgumentWrongOrderForParentArguments
                Incompatible argument type: Required type: \Context. Actual type: \ClassA; File: vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

        ClassArgumentWithWrongParentArgumentsType
                Incompatible argument type: Required type: array. Actual type: \ClassB; File: vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

        ClassArgumentAlreadyInjectedInContext
                Incorrect dependency in class ClassArgumentAlreadyInjectedInContext in E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForContextAggregation.php

\ClassFirst already exists in context object

        ClassArgumentWithAlreadyInjectedInterface
                Incorrect dependency in class ClassArgumentWithAlreadyInjectedInterface in E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForContextAggregaton.php

\InterfaceFirst already exists in context object

        Magento\SomeModule\Model\Five\Test
                Missed required argument factory in parent::__construct call. File: E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Five/Test.php

        Magento\SomeModule\Model\Four\Test
                Extra parameters passed to parent construct: $factory. File: E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Four/Test.php

        Magento\SomeModule\Model\Six\Test
                Incompatible argument type: Required type: \Magento\SomeModule\Model\Proxy. Actual type: \Magento\SomeModule\Model\ElementFactory; File: vendor/magento/framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Six/Test.php

Total Errors Count: 10

Errors during compilation:
        WrongArgumentsOrder
                Incompatible argument type: Required type: \stdClass. Actual type: \ClassExtendsDefaultPhpType; File: vendor/magento/framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php

        ArgumentsOnSeparateLines
                Incompatible argument type: Required type: \stdClass. Actual type: \ClassExtendsDefaultPhpType; File: vendor/magento/framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php

        ClassArgumentAlreadyInjectedIntoContext
                Incorrect dependency in class ClassArgumentAlreadyInjectedIntoContext in E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

\ClassA already exists in context object

        ClassArgumentWrongOrderForParentArguments
                Incompatible argument type: Required type: \Context. Actual type: \ClassA; File: vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

        ClassArgumentWithWrongParentArgumentsType
                Incompatible argument type: Required type: array. Actual type: \ClassB; File: vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

        ClassArgumentAlreadyInjectedInContext
                Incorrect dependency in class ClassArgumentAlreadyInjectedInContext in E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForContextAggregation.php

\ClassFirst already exists in context object

        ClassArgumentWithAlreadyInjectedInterface
                Incorrect dependency in class ClassArgumentWithAlreadyInjectedInterface in E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/Validator/_files/ClassesForContextAggregation.php

\InterfaceFirst already exists in context object

        Magento\SomeModule\Model\Five\Test
                Missed required argument factory in parent::__construct call. File: E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Five/Test.php

        Magento\SomeModule\Model\Four\Test
                Extra parameters passed to parent construct: $factory. File: E:/wamp/www/magento2stable/vendor/magento/framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Four/Test.php

        Magento\SomeModule\Model\Six\Test
                Incompatible argument type: Required type: \Magento\SomeModule\Model\Proxy. Actual type: \Magento\SomeModule\Model\ElementFactory; File: vendor/magento/framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/Six/Test.php

Total Errors Count: 10

Can any one have faced the same error while di:compile?

Best Answer

It is a bug, I have already reported it on GutHub a week ago: https://github.com/magento/magento2/issues/2365

Related Topic