sorry for hijacking the thread for another question.
But since it seems that some of you use Netbeans I would like to ask whether there is some way with netbeans to get code completion on the column names in the model. Yii generates the following phpDoc but Netbeans seems to ignore that.
/**
* The followings are the available columns in table 'xxxx':
* @var integer $id
* @var string $name
* @var string $created
* @var string $updated
*/
does anyone know how to get netbeans to work with that?
you aren’t just helping IDE but converting Yii::app()->mailer to PhpMailer type. I’m not sure if it takes time to do it but generally it’s not the right thing to do.
When you cast an object to an object, then nothing happens; you just get an object. Not very interesting. But if you convert anything else to an object, then you get a new instance of stdClass.
One of the very useful uses of casting to object with Yii is the casting of arrays, which for us object oriented types, makes for some interesting (more concise and readable) alternatives to the way Yii has been coded.
Here’s a good page to get started on the fun – and very tight readable code – you can produce with casting. (For those wondering what’s going on, try using FirePHP on the cast.)
And this is useful too:
$obj = new stdClass();
$obj->data = "Blah";
(Caveat: Note that numeric "keys" in arrays cast to objects will not work. Though this would be inadvisable in any case: $x->3?)
That was just an example. If Yii::app()->mailer is not an instance of PhpMailer then it makes no sense. What I wanted to point out is that you can tell your IDE the class you are working with.
Just after the variable you do want to have completion for.
icevan
Properties like what?
pestaa, auxbuss
Another good thing is converting objects to arrays: (array)$object… but the point was about converting to the same type (PhpMailer in our case) and not to object.
@samdark: Apropos casting an object , you said “I’m not sure if it takes time to do it but…”. I replied to that and raised you ten. But you are right, I forgot I was in PHP-land.