JetBrains PhpStorm, is, surprisingly, an incredible IDE, and works extremely well for Drupal development. We took some time to go through all the various custom settings and get things set up to obey Drupal's coding standards, so we thought we'd share.
First of all, JetBrains's PhpStorm IDE is payware. Second of all, I lost so many hours of my life to frustrations with Eclipse that I was quite happy to fork out the relatively low cost once I'd given it a trial. This is not a post to discuss IDEs or the merits of one platform above another, but suffice is to say that PhpStorm, against all odds, is now my preferred IDE on Linux. YMMV.
I'm going to assume you've set it up, you're using Ubuntu (mostly it won't matter what OS you're on for this blog post) and you're using the Sun version of Java. You are using the Sun version, right?!
Head into the settings from File > Settings.
First, go to Editor and in the Other section, set Strip trailing spaces on Save to All. Also, turn on Ensure blank line before end of file on Save.
Now, expand Editor and head to Editor > Apperance. Turn on Show line numbers unless you love not knowing what line you're on.
Head to Code Style > PHP and make sure Global settings is in use at the top, otherwise you'll have to set these options for each project you work on. Change Tab size to 2 (usually it defaults to 4) and also change Indent and Continuation indent to 2 too.
The rest of the settings in Code style > PHP are actually very sensible, and the only other thing you might want to consider is in the Other tab, turning on Indent code in PHP tags which is not a Drupal standards issue, but I do prefer code that way.
Next, check that under File encodings, the IDE encoding is on UTF-8. You will also want to make sure that under Code Style > General you have set Line separator (for new files) to Unix (this is especially important if you're using Windows) and set Right margin (columns) to 80.
Again, under Code Style > General, set Tab size, Indent, and Continuation indent to 2. Head into each section of Code Style, such as CSS, HTML, etc and make sure all indents are set to 2 on everything.
Drupal has some unusual file extensions and you will need to configure these under PhpStorm to be able to edit them. Head to File Types, click PHP files in the upper pane, and add *.install, *.module, *.profile, *.test, and *.theme.
Inspections are a really powerful way of letting you know you're writing crap code, and will often catch things that most humans will miss. You absolutely don't want inspections to be showing you any false positives if possible, since this will create a 'boy who cried wolf' effect where you won't notice things that are genuinely wrong because you're so accustomed to looking at 'wrong' inspections.
Head to Inspections. For me, it's best to set up the global inspections and use them for all projects, so that's what we'll cover here, although it's also possible to have different inspections for different projects. First, choose Default in the drop-down at the top left (not Project default) and click Share profile.
Turn off the Spelling inspection, unless you really enjoy your IDE telling you that function names are not valid English words! Alternatively you can open it up, choose the Typo inspection, and configure it to only spell check in comments, but I prefer to just disable it and spell things properly myself.
Open up PHP > PHPDoc. You will probably want to turn off Missing @return statement and PHPDoc comment matches function/method signature, and turn on Missing PHPDoc comment. The reason is that under Drupal standards, you don't need to fully document hook implementations. If you leave on those inspections, you will get a lot of errors. On the other hand, you should never have any function that has no documentation for it, even if it's just to say it's implementing a hook, so turning on that inspection will help you out.
Head to PHP > Undefined and turn off undefined variable and undefined field. The reason is that, for whatever reason, it was decided that Drupal should use stdClass objects as data stores, rather than arrays, so you end up with things like $node->title, which, since $node is an object of type stdClass, and not a proper object, generates an undefined field warning. You might need to turn off more of these, so try it out and see how it goes.
Once you've actually opened up a project (which should be as simple as opening a directory, as PhpStorm can detect things like whether it's under git source control), you will want to set up some include paths. This only applies if, like us, you run Drupal multi-site, and your project is just the site itself, rather than the entire Drupal installation. If you added the entire Drupal installation as your project, you needn't worry about this, as it's taken care of for you.
In the project panel, right-click where it says External Libraries and choose Configure Include Paths. Now, add 3 new include paths. These will be /path/to/drupal6/includes, /path/to/drupal6/modules, and /path/to/drupal6/sites/all/modules. This will allow PhpStorm to know about all Drupal's internal functions and any functions inside modules like views where these are stored outside of the current project.
That should be it. You're now good to go develop a Drupal site, module, theme or whatever it is you're doing using PhpStorm. If I did miss anything off this list, do let me know in the comments and I can add it in.
Quick update: Thanks to Timon Royer for letting us know about his PhpStorm and Drupal video which runs you through some of the ways PhpStorm makes your life as a Drupal developer easier. He seems to be a mac user, but we can overlook that, right? ;)