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..
Hello, short question understanding the phpcs rules: Is there a reason using FQCN for every generate
Hello,
short question understanding the phpcs rules: Is there a reason using FQCN for every generated class? From my perspective its more practical to import namespaces since its easier to deal with, even with alias (“… as SprykerBusinessFactory”).
Best
Comments
-
I think it applies just to phpdoc. This way you do not have to scroll or ask your ide in case you wonder what exact class is used in that place. Adding the FQCN to the phpdoc will not create additonal lines as the line is there anyway.
0 -
But lets pick this one
use Spryker\Zed\Kernel\Container; ... /** * @param \Spryker\Zed\Kernel\Container $container * * @return \Spryker\Shared\Kernel\ContainerInterface */ public function provideBusinessLayerDependencies(Container $container): ContainerInterface { ... }
When the Container now changes to another Container from another namespace, you have to change the use statement but also the comment … EACH comment from each function …
I would also think it the way around: Using the IDE would make it more easy to read what specific namespace is meant on that place (by hovering over the class). Just when not using an IDE its more difficult to read since you must scroll.
Even using an alias + convention would be better than an FQCN in that case.
So for me in the end it decreases maintainability for a not really existing advantage in readability (due to using IDE).
0 -
The reason comments/docblocks are ideally FQCN:
They should not require include of use statements for themselves (mixing "functional" vs "non functional"), nor should they be partially invalid/incomplete when being moved or copied to docs or alike.
They serve an important role here as such, even if they might be a bit longer than it appears to be necessary.0 -
Ah okay. Thats a valid point for me … one day we hopefully get rid of all the type stuff in the docs … Thanks a lot guys.
0 -
At least with IDE+tooling they will be auto added/synced pretty much. So no pain/issue for the next years even.
0 -
Would be good anyway to have it not documented twice^^ hopefully we get someday at least that typing stuff fully supported by php
0 -
It isn't documented twice though 🙂 Only once. The other is functional code (with use statements too far away for readability on the types, even more so for screenshots or in PR reviews).
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 77 Spryker News
- 938 Developer Corner
- 795 Spryker Development
- 90 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
- 27 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
- 33 Product & Business Questions
- 69 Spryker Safari Questions
- 50 Random