Skip to content

Fatal error when use ObjectManager static methods #323

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

Open
OleksiiStepanov opened this issue Nov 3, 2021 · 5 comments
Open

Fatal error when use ObjectManager static methods #323

OleksiiStepanov opened this issue Nov 3, 2021 · 5 comments
Labels

Comments

@OleksiiStepanov
Copy link

OleksiiStepanov commented Nov 3, 2021

Preconditions

  1. php 7.4.22
  2. Use v14

Steps to reproduce

  1. create some class with function that call ObjectManager::setInstance($defaultObjectManager);

Expected result

  1. No errors

Actual result

  1. Got error:
    PHP Fatal error: Uncaught TypeError: Argument 2 passed to Magento2\Sniffs\PHP\AutogeneratedClassNotInConstructorSniff::validateRequestedClass() must be of the type int, bool given, called in /home/runner/work/ecommerce-backend/ecommerce-backend/magento-coding-standard/Magento2/Sniffs/PHP/AutogeneratedClassNotInConstructorSniff.php on line 52 and defined in /home/runner/work/ecommerce-backend/ecommerce-backend/magento-coding-standard/Magento2/Sniffs/PHP/AutogeneratedClassNotInConstructorSniff.php:75 Stack trace: #0 /home/runner/work/ecommerce-backend/ecommerce-backend/magento-coding-standard/Magento2/Sniffs/PHP/AutogeneratedClassNotInConstructorSniff.php(52): Magento2\Sniffs\PHP\AutogeneratedClassNotInConstructorSniff->validateRequestedClass() #1 /home/runner/work/ecommerce-backend/ecommerce-backend/magento-coding-standard/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): Magento2\Sniffs\PHP\AutogeneratedClassNotInConstructorSniff->process() #2 /home/runner/work/ecommerce-backend/ecommerce-backend/magento-coding-standa in /home/runner/work/ecommerce-backend/ecommerce-backend/magento-coding-standard/Magento2/Sniffs/PHP/AutogeneratedClassNotInConstructorSniff.php on line 75 Error: Error: Command failed: magento-coding-standard/vendor/bin/phpcs --report=checkstyle --standard=Magento2 app/code/DBI/MessageQueue/Consumer/ConsumerFactory.php app/code/DBI/MessageQueue/Consumer/Isolator.php
@OleksiiStepanov OleksiiStepanov added the bug Something isn't working label Nov 3, 2021
@m2-assistant
Copy link

m2-assistant bot commented Nov 3, 2021

Hi @OleksiiStepanov. Thank you for your report.
To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


@itaymesh
Copy link

itaymesh commented Oct 3, 2023

@OleksiiStepanov hi,
we are getting the same error.
Did you find out how to fix or work around it?

@fredden
Copy link
Member

fredden commented Oct 3, 2023

This was fixed in #336.

@itaymesh please upgrade to version 16 or better.

@itaymesh
Copy link

itaymesh commented Oct 3, 2023

@fredden thanks for your quick reply.
I am already using the latest version.
As a temporary workaround, I added // phpcs:ignoreFile

@fredden
Copy link
Member

fredden commented Oct 3, 2023

@itaymesh Please can you open a new issue with a description of the problem, and ideally a sample file showing the behaviour you're seeing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants