简体   繁体   中英

Netbeans code completion for pseudo properties and methods made from magic functions

I created a component in Yii on top of the normal CComponent. Yii has a useful but quirky process of using magic functions like __get and __set and __call for read-only/write-only properties and for event functions.

When I create an object from the component and attach event handlers to some event in the object, I forfeit the luxury of using code completion because either that property/method does not exist or is protected and so gets answered by __call / __set / __get().

Any idea on how to trick Netbeans code completion into thinking these methods or properties exist? Also is there a way to add PHPDoc comments onto these fake properties and methods?

I guess I found the answer.

http://www.phpdoc.org/docs/latest/references/phpdoc/tags/property.html

The @property tag is used in the situation where a class contains the __get() and __set() magic methods and allows for specific names.

Also:

The @method tag is used in situation where a class contains the __call() magic method and defines some definite uses.

So to add code completion or auto-completion for pseudo properties/methods you would put PHPDoc syntax.

/** 
 * Someclass class
 * @property [Type] [name] [<description>]
 * @method [return type] [name]([[type] [parameter]<, ...>]) [<description>]
 *
 */
class Someclass {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM