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

giovanni.piemontese
giovanni.piemontese 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

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

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    Gerne πŸ™‚

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited September 2021

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    The question is: β€œwhy is getBridgedInterfaceReflection returning null?”

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    yes, right.. why returning null!?

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet
  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited September 2021

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

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

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    ok, i will try.. thanks

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    i give u a feedback if it works

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    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 Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited September 2021

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

    Thank u very much..

  • Chemaclass
    Chemaclass Tech Lead Spryker Solution Partner Posts: 213 πŸ§‘πŸ»β€πŸš€ - Cadet

    Something new that we just learned today πŸ™‚

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    Absolut...

    "you never stop learning" !