Closed
Description
Preconditions
Steps to reproduce
- Run
AutogeneratedClassNotInConstructorSniff
sniff on class with the following code
$objectManager = ObjectManager::getInstance();
$this->_entityFactory = $objectManager->get(EntityFactoryInterface::class);
Expected result
Sniff should not trigger error
Actual result
An error occurred during processing; checking has been aborted. The error message was: Undefined variable:
className in
/var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/PHP/AutogeneratedClassNotInConstructorSniff.php
on line 224
Also please test it with
/**
* Retrieve ObjectManager from global scope
*
* @return void
*/
public function __wakeup()
{
$this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
}