New PHPDoc inspections and quick fixes
There is a number of new PHPDoc inspections available in the latest PhpStorm 2.1 EAP builds which allow to find basic problems in PHP code documenting. These new inspections can be turned on/off in Settings|Inspections|PHP|CodeStyle/PHPDoc. Traditionally each inspection has a quick fix increasing your productivity.
Missing PHPDoc comment
Finds elements (functions, classes, constants etc.) which do not have a PHPDoc comment. Note that the inspection is off by default. When turning it on you can also configure which elements must be documented depending on your code style requirements, see Settings|Inspections|PHP|CodeStyle|Missing PHPDoc Comment:
Well, you still have to write comments to the function and its parameters but that’s what can’t be automated at the moment :-)
Note: in later PhpStorm releases the inspection settings will be moved to the same group with other PHPDoc inspections below: Settings|Inspections|PHP|PHPDoc.
Missing @return tag
The inspection checks that PHPDoc of a function (method) which may return some value doesn’t have an appropriate @return tag. Let’s assume that my
setDisplayMode function returns either 0 or null. In this case the inspection will report “Missing @return tag…” for generated or manually written PHPDoc:
PHPDoc comment matches function/method signature
The inspection reports a problem if a number of parameters described in PHPDoc comment and/or their types do not match a corresponding function or method declaration.
Let’s change the previous example a bit by replacing $total parameter with $disp_option and assigning a default value of 0 to $disp_mode:
You will find that the inspection reports “PHPDoc comment does not match function or method signature”.
“Update PHPDoc Comment” quick fix will change the comment as follows:
Let’s see what has happened. First, $disp_option parameter has been added. Second, $total parameter is now under
@internal tag which excludes it from generated documentation. Note that any comments you might have written for $total parameter are preserved as well as function comments.
Note also that “Update PHPDoc Comment” fix will generate a @return tag if it is missing.
Running PHPDoc inspections in batch mode
The described inspections can be a very good reminder to keep your code documentation up-to-date. And let’s be honest, that’s something we often forget to do :-)
Working with Windows Azure SQL Database in PhpStorm
PhpStorm provides us the possibility to connect to Windows Azure SQL Database right from within the IDE. In this post, we’ll explore several options that are available for working with Windows Azure SQL Database (or database systems like SQL Server, MySQL, PostgreSQL or Oracle, for that matter): …
Change signature refactoring in PhpStorm
A very powerful refactoring is the Change signature refactoring in PhpStorm. It enables us to modify a function signature in many ways: we can change the function name, change its visibility, add, remove and reorder parameters as well as rename parameters. (more…)…
Folding for imports in PhpStorm 6.0
In PhpStorm 6, we've introduced code folding for imports. Any list of imports will now be folded into a single line. This greatly reduced clutter in your editor when having a lot of imports! (more…)…
Drag & Drop Project Files to Remote Hosts in PhpStorm
The Remote Host pane allows us to work directly on a remote server through FTP, FTPS, SFTP or a local/network folder. A lot of people asked us to add drag & drop to the Remote Host pane in PhpStorm. Good news: PhpStorm 6 comes with drag & drop as well as copy & paste support from the pro…