cancel
Showing results for 
Search instead for 
Did you mean: 

Don't supports anonymous classes from php7

0 Kudos

Don't supports anonymous classes from php7

Feature request from Galillei, posted on GitHub Jun 15, 2016

Steps to reproduce I use Magento 2.0.5 on php 7.0.2 and try it use with anonymous classes. It's work correctly before i try to use production mode with di compile. for example

    public function getDebug()
    {
        return (new class($this->_loadOrder){
            protected $loadOrder;
            public function __construct($loadOrder)
            {
                $this->_loadOrder = $loadOrder;
            }
            public function getOrderStatus()
            {
                return $this->_loadOrder->getStatus();
            }
        });
    }

And try to run follow command ./bin/magento setup:di:compile
i get error [ReflectionException] Class \Rcklss\ShipWorks\Model\$this does not exist

5 Comments
Not applicable
Status changed to: Investigating
 
Not applicable

Comment from xi-ao, posted on GitHub Aug 23, 2016

This is a nasty limitation of the compiler indeed.

Not applicable

Comment from joni-jones, posted on GitHub Mar 28, 2017

Hi, @galillei, thanks for reporting. I've created internal ticket (MAGETWO-66828).

Not applicable

Comment from dank00, posted on GitHub Jul 23, 2017

@joni-jones any update on this? Finding this open issue has ruined my day somewhat.

Not applicable

Comment from joni-jones, posted on GitHub Jul 24, 2017

Hi, @dank00, I'm not sure if it will be done before Magento 2.3 release. This issue was converted to feature because requires refactoring of a lot of functionality which includes code auto generation, pluginization, etc.