Code completion in phpStorm with WordPress

phpStorm Logo I use phpStorm pretty much exclusively for PHP development, for over a year.
It simply has some awesome features.

But there are some things that people tend to complain about.
One of the biggest I am going to show you how to fix.

Current Helpers phpStorm Helpers

phpStorm by Jetbrains uses a stricter approach for code completion than most PHP IDE’s.
They index all constructs but for everything else phpStorm requires proper phpDoc annotations.

The reason behind this I think is simply for performance to keep it a bit litter and to have faster start-ups.

I will be doing a few of these examples for popular open source projects that have code completion issues do to their standards or simply not having phpDocs at all.

Once you get the hand of this, its pretty easy to do and works quite well.
Some of these issues are seen in all IDE’s not just phpStorm

So here we go, digging into the code.
The comments explain just about everything you need to know.

Basically for accessing WordPress’s functions and methods that are mostly used eg wpdb, you add this file to the WP root https://gist.github.com/1105126.

I prefer as in the comments of the file to have the class named wpdb and remove the extends.
Like this,

Then I drop that file in the WP root.
phpStorm will index the construct and use the listed properties in that file for code completion within the wpdb class.

You should not get duplicate class errors because we are not instantiating it.
Its just there for phpStorm.

I will be doing one of these for phpBB3 and also CodeIgniter so you may want to subscribe and follow future posts.
Current Helpers phpStorm Helpers