Skip to content

AutogeneratedClassNotInConstructorSniff fails with specific code #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xmav opened this issue Oct 14, 2021 · 1 comment · Fixed by #319
Closed

AutogeneratedClassNotInConstructorSniff fails with specific code #314

xmav opened this issue Oct 14, 2021 · 1 comment · Fixed by #319
Assignees
Labels
bug Something isn't working Progress: done

Comments

@xmav
Copy link
Contributor

xmav commented Oct 14, 2021

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();
    }
@xmav xmav added the bug Something isn't working label Oct 14, 2021
@m2-assistant
Copy link

m2-assistant bot commented Oct 14, 2021

Hi @xmav. Thank you for your report.
To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Progress: done
Projects
None yet
2 participants