Calling Developers!
We are reenergizing our code contribution process! Learn More

What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Good Morning everyone, i have a strange error from Architecture check that run as git pre-commit ho

Options
giovanni.piemontese
giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet

Good Morning everyone,

i have a strange error from Architecture check that run as git pre-commit hook.. Here the error:

[Command "Architecture check" (file: ./src/Pyz/Zed/Cart/CartDependencyProvider.php) fails] PHP Fatal error:  Uncaught TypeError: Argument 2 passed to ArchitectureSniffer\Common\Bridge\BridgeMethodsRule::findNotMatchingMethodsForBridgeInterface() must be an instance of ReflectionClass, null given, called in /Users/gpiemontese/Projects/projekt.local/project/vendor/spryker/architecture-sniffer/src/Common/Bridge/BridgeMethodsRule.php on line 98 and defined in /Users/gpiemontese/Projects/projekt.local/project/vendor/spryker/architecture-sniffer/src/Common/Bridge/BridgeMethodsRule.php:177
Stack trace:
#0 /Users/gpiemontese/Projects/projekt.local/project/vendor/spryker/architecture-sniffer/src/Common/Bridge/BridgeMethodsRule.php(98): ArchitectureSniffer\Common\Bridge\BridgeMethodsRule->findNotMatchingMethodsForBridgeInterface(Object(PHPMD\Node\InterfaceNode), NULL)
#1 /Users/gpiemontese/Projects/projekt.local/project/vendor/spryker/architecture-sniffer/src/Common/Bridge/BridgeMethodsRule.php(61): ArchitectureSniffer\Common\Bridge\BridgeMethodsRule->verifyInterface in /Users/gpiemontese/Projects/projekt.local/project/vendor/spryker/architecture-sniffer/src/Common/Bridge/BridgeMethodsRule.php on line 177

I don't understand where is the problem... Has anyone any idea how to fix it?

Thank u all in advance!

Comments

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    Options

    can you share your ./src/Pyz/Zed/Cart/CartDependencyProvider.php ?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    Gerne 🙂

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    edited September 2021
    Options

    Do you have an interface for that Bridge? CartToQuoteFacadeBridge 🤔

    The failing is because BridgeMethodsRule::getBridgedInterfaceReflection() is returning a null , and that’s being used in BridgeMethodsRule:98 when calling the findNotMatchingMethodsForBridgeInterface that expects a ReflectionClass and it doesn’t allows null. That’s why you get that TypeError.

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    yes... i have an interface...
    Do u think is that the problem?

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    Options

    The question is: “why is getBridgedInterfaceReflection returning null?”

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    yes, clear... i know.. but why it happend?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    yes, right.. why returning null!?

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    Options

    Can you share the CartToQuoteFacadeBridge ? and maybe also the interface?

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options
  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    edited September 2021
    Options

    I know it will sound stupid, but try adding the constructor to your child class (I know, it’s not necessary from code perspective, but maybe the sniffer is not that clever after all…)

    /**
     * @param \Spryker\Zed\Quote\Business\QuoteFacadeInterface $quoteFacade
     */
    public function __construct($quoteFacade)
    {
        $this->quoteFacade = $quoteFacade;
    }
    
  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    ok, but then i have also to call the parent construct or not?

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    Options

    becase, according with that method to avoid getting null you need:
    1. a constructor
    2. a PHPDoc on the constructor
    3. one argument on the constructor
    4. that argument must be the interface of the class that you are bridging

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    ok, i will try.. thanks

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    i give u a feedback if it works

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    Options

    yes, yes, that’s correct, using the parent constructor would better 🙂

    /**
     * @param \Spryker\Zed\Quote\Business\QuoteFacadeInterface $quoteFacade
     */
    public function __construct($quoteFacade)
    {
        parent::__construct($quoteFacade);
    }
    
  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    edited September 2021
    Options

    YES... U are right!!! it works!

    Thank u very much..

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 🧑🏻‍🚀 - Cadet
    Options

    Something new that we just learned today 🙂

  • giovanni.piemontese
    giovanni.piemontese Technical Lead @ Löffelhardt Spryker Solution Partner Posts: 871 🧑🏻‍🚀 - Cadet
    Options

    Absolut...

    "you never stop learning" !