Extending CWebUser as WebUser

Hi guys,

I just created the Yii.php file as described in this page for code autocomplete fixing in NetBeans.

It worked good. The problem is Netbeans is identifying Yii::app()->user as CWebUser and not WebUser (where I put my extending methods).

How can I tell Netbeans the class of the user is WebUser?

Ps.: The methods are working, the problem is only with autocomplete.

Thanks!

Almir

This may not be the perfect solution, but I have been using this for a while without any problems.

The


Yii::app()->user

property is defined in framework/base/CApplication.php around line 80 (where the framework folder is your yii framework folder):


 * 

 * @property CWebUser $user The user component

 *

 * @author Qiang Xue <qiang.xue@gmail.com>

 * @package system.base

 * @since 1.0

You can modify the $user property type from CWebUser to WebUser.

I know, that the no. 1 "rule" is not to modify the framework files. However I think this is the fatest solution and this is only a slight change.

Hi,

I tried, but the CWebUser declaration doesn’t exists in framework/base folder. Neither in CApplication or in another files.

There is a property in framework/web/CWebApplication with the line:




* @property CWebUser $user The user session information.



I changed It to WebUser, restarted NetBeans, but no effect.

Regards,

Almir

This is what I do:

Add a new file where you declare class Yii again and add to the class documentation the properties you need. I know this make autocomplete show up two Yii classes, but it’s a solution since one of the items will have the right suggestions.




/**

 * My Applications new instance of Yii class.

 * @property WebUser $user

 */

abstract class Yii {

}



Have you seen this article about using NetBeans for Yii Framework?

http://www.yiiframew…d-yii-projects/