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
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?
Comments
-
Hm, if I rename
$sequenceNumberSettingsTransfer
to$sequenceNumberSettings
in interface and implementation, it will pass validation. Is there a length limitation for var names?0 -
for ($i = 0; $i < $countParameters; $i++) { if ((string)$firstMethodParameters[$i] !== (string)$secondMethodParameters[$i]) { return false; } }
0 -
they just have to match
0 -
They did match, that's the confusing thing actually.
0 -
strange, some cache maybe?
0 -
or not synced
0 -
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.0 -
still, makes sense to check if classes do match in container
0 -
but I guess you're comparing bridge to it's declared interface
0 -
you chould also take into account SequenceNumberFacadeInterface
0 -
there it's
public function generate(SequenceNumberSettingsTransfer $sequenceNumberSettings);
0 -
Might be, yes. But honestly, how stupid is that? Transfer vars are called $...Transfer most of the times, all across the code.
0 -
that's true, some older spryker modules would not pass new sniffers themselves
0 -
the rule itself makes sense to me, it makes sure that bridge 100% matches facade interface, so that you're not creating adapter instead
0 -
btw why would you create bridge in project? or is it separate module?
0 -
But you should be free to choose var names. Forcing somebody to stick to made up var naming conventions seems useless to me.
0 -
Yes, the bridge is used to call a facade from a different module.
0 -
bet it was just easier to implement check like this, exact naming doesn't matter for interpreter of course
0 -
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
0 -
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.0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 75 Spryker News
- 924 Developer Corner
- 783 Spryker Development
- 88 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 25 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random