X

An Oracle blog about NetBeans for PHP

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!

Join the discussion

Comments ( 4 )
  • Tom Thursday, October 4, 2012

    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 :)


  • guest Friday, October 5, 2012

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


  • Tuner Friday, October 5, 2012

    Fantastic! Thank you!


  • dGo Monday, April 15, 2013

    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;

    }

    }


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

Integrated Cloud Applications & Platform Services