NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
yii framework code completation


Joined: 04 Apr 2011
Posts: 1
Reply with quote
hi, i'm trying yii framework but when i try code-completion on objects i receive the error:
Failed to identify type of $XXXX global variable

(i.e. in _form.php whe i try on $model->.... )

In my project / includes all classes and files are set.

Has anyone used phped with yii framework and solved this problem?

Hi.
View user's profileFind all posts by tajettgiSend private message
Guru master

Joined: 24 Jul 2009
Posts: 737
Reply with quote
I've never used yii, but I just had a quick look at it and _form.php is a template with $model being externally defined. During coding, PhpED has no way of knowing what object class $model is defined as. This is a common problem with templates.

I don't know off-hand what class $model is either as I don't have an installed project to run, but if you breakpoint this line in _form.php then you can use the debugger to find out what the class name is:

Code:
<?php echo "<?php echo \$form->errorSummary(\$model); ?>\n"; ?>


Then you can fake a variable declaration to that class name so that you can get code completion to work:

Code:
<?php
    /** @var CLASS_NAME */
    if (false) $model = $model; // $model never gets assigned, but causes PhpED to use the @var
?>
<?php echo "<?php echo \$form->errorSummary(\$model); ?>\n"; ?>


You will now hopefully get code completion on $model. I've used this trick and it does work on probably most object variables, except $this because PhpED does not allow that to be re-assigned to an arbitrary object.

Bear in mind that it is also possible that $model could be a different object class on each call, so it might not be consistent.
View user's profileFind all posts by plugnplaySend private message
yii framework code completation
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic