Change variable type

Hi there. I learn how to write simple plugin for phpstorm.

My new chalenge is next:

*@iterate-object Token
class TokenCollection implements Iterator {


class Token {
    public function getId() {

$it = new TokenCollection();
foreach ($it as $key => $value) {

I want to suggest all methods and properties from object Token when i press Ctrl+space on $value->

In other words type of $value is class Object of Token.

At my first step, i try to change $value type in PsiReferenceContributor. Byt i can`t catch it.

I try to suggest it via DefaultCompletionContributor. I fill suggest elements with method names. But name of method does not corespond to class method. So it is wrong step for me.

My questin:
How can i set that  $value is coressponding to Token class?

Screenshot from 2013-12-03 11:52:28.png
Comment actions Permalink

You need to implement com.intellij.codeInsight.completion.CompletionContributor - check it's documentation first.

Comment actions Permalink

Thanks for help.

Comment actions Permalink

Using PhpTypeProvider2 i done may task for 98%

What i have done.
file User/Edit.php     contain Site_User_Edit_Controller

I have several html files

file View/UserEdit.html and file View/UserEdit-row.html
In this files $this is instance of Site_User_Edit_Controller. I use PhpTypeProvider2 to make completion of methods and properties of class Site_User_Edit_Controller
All works fine. Plus I use CompletionContributor to suggest $this variable in this files;

But there is one feature I want to do.
When I move mouse to $this and press Ctrl+click IDE does not go to class. it is strange however IDE knows about $this type but naviagtion to class is not available.

Naviagtion is available only if I use phpdoc

  /** @var $this Site_User_Edit_Controller */

How to avoid writing this phpdoc comments and tell IDE that $this is instance of class Site_User_Edit_Controller?

Comment actions Permalink

Answer to my question: implement


Please sign in to leave a comment.