Skip to content

AutogeneratedClassNotInConstructorSniff fails with specific code #314

Closed
@xmav

Description

@xmav

Preconditions

Steps to reproduce

  1. 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();
    }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions