How to teach PHPStorm to ‘Go To Implemenation’ of Codeception Modules and Helpers?

Vastly
2 min readMar 17, 2020

--

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.

Go To Implementation(s) menu in PHPStorm

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:

“Implementation” of codeception assertion is not the right one by default.

Fortunetely, there is an easy way to walk around it!

First, exclude test/support/_generated directory in PHPStorm’s settings:

shut down _generated directory

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:

Adding Modules & Helpers as mixins to enable ‘go to implementation’ functionality

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?

--

--

Vastly
Vastly

Written by Vastly

Making the world a better place for someone else. https://github.com/ivastly/

No responses yet