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

I'm running the architecture sniffer and getting an error that I don't understand. It's about attach

Posts: 287 🧑🏻‍🚀 - Cadet

I'm running the architecture sniffer and getting an error that I don't understand. It's about attached interface and its implementation. Command output keeps telling me that the bridge method is different from the one defined in the interface.

docker/sdk console code:sniff:architecture -vvv
-->  DEVELOPMENT MODE   
Store: DE | Environment: docker.dev
Run Architecture Sniffer for PROJECT
/data/src/
 Bridges: The bridge interface has incorrect method 'generate' signature. That violates the rule "All bridge methods must have exactly the same signature as their interface" (l. 12)
 Spryker > BridgeMethodsRule
1 violations found

Next thing I did was to edit vendor/spryker/architecture-sniffer/src/Common/Bridge/BridgeMethodsRule.php temporarily to produce some additional log output. Turns out that the parameter comparison is failing:

Parameter #0 [ <required> Generated\Shared\Transfer\SequenceNumberSettingsTransfer $sequenceNumberSettingsTransfer ]
Parameter #0 [ <required> Generated\Shared\Transfer\SequenceNumberSettingsTransfer $sequenceNumberSettings ]

First line is the one from the interface method, second one from its implementation.
Crazy thing is that the second line doesn't reflect the actual argument name from the Bridge class. How can that be?

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Posts: 287 🧑🏻‍🚀 - Cadet

    Hm, if I rename $sequenceNumberSettingsTransfer to $sequenceNumberSettings in interface and implementation, it will pass validation. Is there a length limitation for var names?

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet
    for ($i = 0; $i < $countParameters; $i++) {
                if ((string)$firstMethodParameters[$i] !== (string)$secondMethodParameters[$i]) {
                    return false;
                }
            }
    
  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    they just have to match

  • Posts: 287 🧑🏻‍🚀 - Cadet

    They did match, that's the confusing thing actually.

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    strange, some cache maybe?

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    or not synced

  • Posts: 287 🧑🏻‍🚀 - Cadet

    I cleared all caches several times.
    Sync issues shouldn't be the reason, afaik that is more something happening on Mac OS. I'm working on Ubuntu, never had issues so far.

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    still, makes sense to check if classes do match in container

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    but I guess you're comparing bridge to it's declared interface

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    you chould also take into account SequenceNumberFacadeInterface

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    there it's public function generate(SequenceNumberSettingsTransfer $sequenceNumberSettings);

  • Posts: 287 🧑🏻‍🚀 - Cadet

    Might be, yes. But honestly, how stupid is that? Transfer vars are called $...Transfer most of the times, all across the code.

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    that's true, some older spryker modules would not pass new sniffers themselves

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    the rule itself makes sense to me, it makes sure that bridge 100% matches facade interface, so that you're not creating adapter instead

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    btw why would you create bridge in project? or is it separate module?

  • Posts: 287 🧑🏻‍🚀 - Cadet

    But you should be free to choose var names. Forcing somebody to stick to made up var naming conventions seems useless to me.

  • Posts: 287 🧑🏻‍🚀 - Cadet

    Yes, the bridge is used to call a facade from a different module.

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet

    bet it was just easier to implement check like this, exact naming doesn't matter for interpreter of course

  • Sprykee Posts: 154 🧑🏻‍🚀 - Cadet
    edited June 2021

    imagine you have calculate(int $price, int $tax) in facade but bridge is defined as calculate(int $tax, int $price). It's still two int parameters but logically you would have to swap parameters inside bridge

  • Posts: 287 🧑🏻‍🚀 - Cadet
    edited June 2021

    Okay, that is a sensible example. You got me convinced.
    Things like these would be much easier to find and fix if the console command gave some useful output, though.

Welcome!

It looks like you're new here. Sign in or register to get started.