Generated Methods with Type Hints

Hi all! Today we would like to introduce you just another feature from upcoming NetBeans 7.3. It's about generating setters, constructors and type hints of their parameters.

For years, you can use Insert Code action to generate setters, getters, constructors and such. Nothing new. But from NetBeans 7.3 you can generate Fluent Setters! What does it mean? Simply that $this is returned from a generated setter. This is how it looks like:

Fluent Setters

Fluent Setters

But that's not everything :) As you know, before a method is generated, you have to choose a field, which will be associated with that method (in case of constructors, you choose fileds which should be initialized by that constructor). And from NetBeans 7.3, type hints are generated automatically for these parameters! But only if a proper PHPDoc is used in a corresponding field declaration, of course. Here is how it looks like.

Generated Type Hints

And that's all for today and as usual, please test it and if you find something strange, don't hesitate to file a new issue (product php, component Editor). Thanks a lot!

Comments:

you could also add generate from navigator view , right click on element or class and then select option generate , it will be a nice feature :)

Posted by Tom on October 04, 2012 at 04:03 PM CEST #

why the size netbeans 7.3 for php become 111Mb,but in 7.2,it is only 50M.

Posted by guest on October 05, 2012 at 01:26 PM CEST #

Fantastic! Thank you!

Posted by Tuner on October 05, 2012 at 10:01 PM CEST #

it would be nice, when generating the getters and setters, that the PHPDOC would be generated as well...

<?php

class Foo
{
/**
* @var string
*/
protected $_string;

/**
* @var Bar
*/
protected $_bar;

/**
* @return string
*/
public function getString() {
return $this->_string;
}

/**
* @param string $string
* @return Foo
*/
public function setString($string) {
$this->_string = $string;
return $this;
}

/**
* @return Bar
*/
public function getBar() {
return $this->_bar;
}

/**
* @param Bar $bar
* @return Foo
*/
public function setBar($bar) {
$this->_bar = $bar;
return $this;
}
}

Posted by dGo on April 15, 2013 at 11:42 AM CEST #

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