PHPDoc for all magic properties of all classes derived from CComponent

I was disappointed by lack of code completion support when using Yii in JetBrains PHPStorm. There’re plenty of requests to add support for magic properties and all things magic both in PhpStorm bug tracker and here on the forum. I can’t wait, I want to develop. So here’s my quick fix.

I’ve written a script which finds PHPDoc comments for getters and setters, then writes text file with comments. It relies on proper existing comments and proper code formatting. Haven’t noticed any problems with the script, but it’s easily breakable. The script is released into public domain.

I’ve decided to use only @property tags, because PHPStorm doesn’t seem to properly support @property-read and @property-write (they’re displayed in code completion, but comment is ignored on Ctrl+Q).

2162

phpdoc-trunk-simple.diff.txt
— diff file for current trunk (rev. 3422)

2163

GenPhpDocProp.php.txt
— script used to generate comments

2164

phpdoc-trunk-simple.txt
— generated file with comments (only @property)

2165

phpdoc-trunk-complex.txt
— generated file with comments (also with @property-read and @property-write)

Please note, PHPStorm decided to force newlines on the end of file and to trim unneceassary whitespace. If that’s a problem with your code committing convention, it should be easy to revert those lines.

I hope to see PHPDoc comments included in the next version and updated as long as it’s necessary. There’re feature requests for PHPStorm which, once implemented, would make this copy-pasting redundant, but that could take a long time.

I’d also like to hear ideas how to include components from application config in code completion. Currently I have to use dirty hacks:


[ index.php ]


/** @return CMyApplication */

function app()

{

    return Yii::app();

}


[ intellisense.php ]


/**

 *  @property CLogRouter $log

 */

class CMyApplication extends CWebApplication{}



Stuff like this (suggested here on th forum) doesn’t seem to work:


[ intellisense.php ]


class Yii extends Yii

{

   /** @return CMyApplication */

   static public function app(){}

}

But it’s probably related to bugs in PHPStorm which seems to have problems when class is declared in multiple files.

P.S. “You aren’t permitted to upload this kind of file” error for diff files was unexpected…

Поспешишь — людей намешишь… Х)

Discovered abstract classes had been skipped. ::)

2169

GenPhpDocProp-2.php.txt
— fixed script for generating comments

2170

phpdoc-trunk-simple-2.diff.txt
— diff file for current trunk (rev. 3422)

2167

phpdoc-trunk-simple-2.txt
— generated file with comments (only @property) for trunk

2168

phpdoc-1.1.8-simple-2.txt
— generated file with comments (only @property) for 1.1.8

And finally… yii-framework-1.1.8-with-phpdoc.zip size=1[/size] — yii 1.1.8 framework directory with PHPDoc comments applied. You can copy and use it right away, yay!

P.S. Limitations like 0 comments within 10 minutes from registration, and 3 comments within 24 hours are annoying. <_< I can’t even edit my posts.

Thanks for your contribution. Applied to trunk.

The link does not work. Could you create a mirror for this archive?

Thank you.

My website is up now, but just in case…

framework.zip size="1"[/size]

framework.rar size="1"[/size]