X

An Oracle blog about NetBeans for PHP

Introduce Variable QuickFix

Guest Author

Last week I've got a question: "I need to explain when the Introduce Variable hint is invoked?" and I've realized that I could mention it briefly in this weblog because I'm not sure how many of you have already noticed it. I like this feature because I have a feeling that it boost my productivity. As an example imagine following common OOP piece of code:

<?php
$simpleClass = new SimpleClass();
?>

To create an instance of a class, a new object must be created and
assigned to a variable. An object will always be assigned. This hint appeares just in the moment when assignment is ommited:

Introduce Variable Hint Annotation

Then Alt+Enter is enough to fix it and assign it to a variable.

The other typical use cases when this hint appears: function, method invocations. So, on every line in the following piece of code this hint should appear:

<?php
new SimpleClass();
$simpleClass->getSimpleValue();
SimpleClass::getSimpleKind();
calculate();
?>

The implementation doesn't try to find out whether the function or method really returns a value, it's left just up to the user's decision whether to use or not use this hint.  

The last note I would like to mention is that the name of generated variable on left side is taken just from the right hand side and is preselected to be able to modify it instantly. See the screenshot:

Introduce Variable Hint

Please comment or report bugs, I will wait for your feedback.

Join the discussion

Comments ( 4 )
  • Medyum Hoca Friday, July 24, 2009

    Thanks


  • a&#351;k resimleri Tuesday, July 28, 2009

    Thanks..


  • medyum Thursday, August 13, 2009

    thanks a lot!


  • links of london Thursday, October 29, 2009

    It was a very nice idea! Just wanna say thank you for the information you have shared. Just continue writing this kind of post. I will be your loyal reader. Thanks again.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.