Cast variable to enable autocomplete in NetBeans

Hello, this post is for my own reminder - I bet that in a week I forgot it ;)
I hope someone will find it helpfull too.

One of the most importand tool in any IDE is autocomplete.
You don't need to look in documentation to find method what you are exactly looking for. With autocomplete its extremely faster - well we all knew that.

But the problem in NetBeans comes when you get variable from some method and this variable starts to represent object. Like in this example:
$doc = new DOMDocument();
$form = $doc->getElementsById("myform");
$attr = $form->
So now you want do the magic with new DOMElement object inside $form variable.
You type $form->, hit Ctrl+Space... and NetBeans says 'No suggestions' - what a pity.

Sometimes I use VisualStudio IDE for C# projects and in this situations VS works with no problem. Just using bracket's casting like in this pseudocode:
$attr = (DOMElement)$form->getAttribute("action");

But how to do it in NetBeans? Here is the answer:
$doc = new DOMDocument();

/* @var $form DOMElement */

$form = $doc->getElementsById("myform");
$attr = $form->getAttribute("action"); 
As you can see we need to add comment line where we define the variable and its type. After that Ctrl+Space combination gives us very nice list of methods. Little odd solution for me but its better than nothing ;) Now my work gets pleasant again.