I'm trying to re-compile using

php bin/magento setup:di:compile

But when I run this command, I get:

Fatal error: Cannot use 'Void' as class name as it is reserved in /var/www/html/magento/vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Void.php on line 9

I am running PHP 7.1.0-alpha.

4 Answers 4


I don't think Magento 2 is yet compatible with php 7.1-alpha, but this is an alarm signal.
I think you should report this on github.
It could be an issue in the near future,


Here is how to fix it:

  1. edit vendor/magento/module-sales/etc/webapi.xml line 112:

    - <route url="/V1/invoices/:id/void" method="POST">
    + <route url="/V1/invoices/:id/voidInvoice" method="POST">
  2. edit vendor/magento/module-sales/Block/Adminhtml/Order/Invoice/View.php line 242:

    - return $this->getUrl('sales/*/void', ['invoice_id' => $this->getInvoice()->getId()]);
    + return $this->getUrl('sales/*/voidInvoice', ['invoice_id' => $this->getInvoice()->getId()]);
  3. edit vendor/magento/module-sales/Block/Adminhtml/Order/Creditmemo/View.php line 183:

    - return $this->getUrl('sales/*/void', ['creditmemo_id' => $this->getCreditmemo()->getId()]);
    + return $this->getUrl('sales/*/voidCreditmemo', ['creditmemo_id' => $this->getCreditmemo()->getId()]);
  4. edit vendor/magento/module-sales/Controller/Adminhtml/Order/Invoice/Void.php line 9:

    - class Void extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
    + class VoidInvoice extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
  5. edit vendor/magento/module-sales/Controller/Adminhtml/Order/Creditmemo/Void.php line 10:

    - class Void extends \Magento\Backend\App\Action
    + class VoidCreditmemo extends \Magento\Backend\App\Action
  6. rename




  7. rename




taken from https://mage2.pro/t/topic/2433/2

  • you are very welcome sir Commented Mar 13, 2017 at 16:32
  • in Magento Enterprise mv vendor/magento/module-reward/Model/Action/Creditmemo/Void.php vendor/magento/module-reward/Model/Action/Creditmemo/VoidCreditmemo.php in line 8 change class Void to class VoidCreditmemo Commented Jan 25, 2018 at 11:40
  • @KonstantinGerasimov, Is there any patch available for M230 ? Commented Mar 4, 2020 at 10:44

Instead of modifying the core magento vendor files to resolve the issue it would make more sense to use the right php version. Depending on what you are using, it should be easy enough to set a BASH configuration for a particular php bin location.


This is no longer an issue for Magento 2.2 - Magento 2.1 was not PHP7.1 compatible.

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.