How to teach PHPStorm to ‘Go To Implemenation’ of Codeception Modules and Helpers?
If you use Codeception and PHPStorm all together, this article is for you. Of course “Go To Implementation(s)” functionality is probably in your blood already, and you likely use the hotkey (⌘ + B on Mac) countless times a day.
If you adopt Codeception seriously, you have probably created some of your own Modules and Helpers. Even if not, it could be really useful to go to Codeception’s native methods implementation instantly.
Surprisingly, it is not possible out of the box. Codeception uses code generation, that’s why you end up in front of something like this, if you try:
Fortunetely, there is an easy way to walk around it!
First, exclude test/support/_generated directory in PHPStorm’s settings:
Second, make use of @mixin
annotation, and add all your own, native and third-party modules and helpers as mixins to ApiTester
class, which was created ages ago, when you introduced Codeception to the project:
Voilá! Go to Implementation
works like a charm after these two easy steps.
Conclusion
Using mixin annotation and excluding a folder in PHPStorm’s Preferences, we enabled Go to Implementation
functionality for Codeception modules and helpers back again. However, adding new modules and helpers as mixins is still a manual work, i.e. you need to do it by yourself after adding one more module to the project.
Maybe this post can inspire someone to implement this functionality in Codeception natively as a true gesture of gratitude and support of FOSS. What do you think, Michael Bodnarchuk @davert?