cancel
Showing results for 
Search instead for 
Did you mean: 

Don't supports anonymous classes from php7

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

6 Comments
apiuser
New Member
Status changed to: Investigating
 
apiuser
New Member

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

This is a nasty limitation of the compiler indeed.

apiuser
New Member

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

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

apiuser
New Member

Comment from dank00, posted on GitHub Jul 23, 2017

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

apiuser
New Member

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.

anemitoff
Senior Member

Any update on this 2 year old issue, as it is still a problem in 2.2.9 ?!?!