Introduce Variable QuickFix

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.

Comments:

Thanks

Posted by Medyum Hoca on July 24, 2009 at 05:45 AM CEST #

Thanks..

Posted by aşk resimleri on July 28, 2009 at 10:42 PM CEST #

thanks a lot!

Posted by medyum on August 13, 2009 at 09:19 AM CEST #

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.

Posted by links of london on October 29, 2009 at 08:26 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blogs is written by NetBeans developers who contribute to the PHP support mainly.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today