Ide Tricks For String $Classname?

I don’t know if anyone has asked about this, but there is something that keeps bugging me when coding using Yii.

As you know, when there are several method that require us to pass the string version of a class,

.e.g. CController:beginWidget, CController::endWidget, CController::widget




$controller->beginWidget('application.components.MyCustomWidget', array());






$controller->widget('application.components.MyCustomWidget', array());






$controller->endWidget('application.components.MyCustomWidget');



or when we are customizing pager for CBaseListView (CGridView, CListView, etc).




$controller->widget('CGridView', array(

    //skip

    'pager' => array(

        'class' => 'application.components.MyCustomPager'

    ),

));



I feel using this 'class' => $className is really hard for debugging. I’m using Netbeans for my main IDE, and to look at the MyCustomWidget I need to browse the project file tree to find the MyCustomWidget.php (or do a search).

I think it would be good if we can just jump to the source file of the class by the class name. But since it’s in string, Netbeans can not detect if it represents a class.

It would be really nice if we can do something like CActiveDataProvider.




$dataProvider = new CActiveDataProvider(User::model());



of course, the purpose is not for IDE but for passing Finder into the data provider. But it’s really better than




$dataProvider = new CActiveDataProvider('User');



since I can just click on the User::model() to jump to User.php file.

The nearest thing I have to make it easier to jump between class source file is by using /* @var comment.

.e.g.




/* @var $widget MyCustomWidget */

$controller->beginWidget('application.components.MyCustomWidget', array());



fortunately Netbeans can detect the MyCustomWidget inside the comment as a class name, and I can just press Ctrl and click the MyCustomWidget and the IDE will jump to the MyCustomWidget.php. The $widget string is a little bit wasteful, but I can live with that.

I’m just asking if anyone feels the same and if you have a better solution for this.