Parameter Code Completion in PhpStorm 2016.2

In PhpStorm 2016.2, we’ve introduced a new “automatic” live template that makes it easier to complete the parameters passed into functions, methods, or class constructors. Let’s take a look at how this works.

Completing parameters with already defined variables is a pain. This update to 2016.2 really helps speed up the process of ensuring the correct variables are passed to the right parameter when you’re invoking a function, method, or instantiating a new class.

To invoke the magic live template, use the params keyword as the first parameter of the function, method, or class. This will automatically complete the parameters with the variable names defined in the function declaration, but will allow you to use Enter or Tab to move to the next parameter (you can use Shift+Tab to move backwards through parameters).


Notice how PhpStorm will suggest the variables based on their type (if it can infer the type from type hints or docblocks) to make finding the correct variable as easy as possible. This will work exactly the same for method parameters, and class constructors.

On its own, this really helps, but because YOLO, you can turn this functionality on by default. Then, when you invoke completion on the method, function or class, the parameters are automatically added, and your caret is placed on the first parameter ready to complete.

To turn this functionality on, you need to open your preferences pane and navigate to Editor | General | Smart Keys and then enable the option Enable smart function parameters completion.

Give it a try and let me know what you think.

– Gary and the PhpStorm Team

About Gary Hockin

Gary Hockin has been creating code to power web applications for 15 years, the last three of them at an extraordinary level. He is handsome, talented, funny and articulate, and also extremely modest. Gary is a valued contributor to Zend Framework 2 and is a member of the community review team. He's married and has two wonderful children, and when he's not coding, writing about code, speaking about code or reading about code, he can usually be found in the pub playing pool.
This entry was posted in Cool Feature. Bookmark the permalink.
  • Juan

    Cool feature… Thanks !!!

  • Abdellatif Landolsi

    nice theme, how can I get it?

    • Anna Lebedeva

      It’s Material Peacock color scheme

      • Abdellatif Landolsi

        Many thanks for the prompt reply.

  • WonYong Jung

    Cool feature!

    But unfortunately this feature is not worked for me.

    I’m using PHPStorm with PHP 5.6 set to PHP5.3 compile level on Ubuntu 16.
    When I write code for call method of class, “smart function parameters completion” appears on suggest list, but not inserted anything when I select it.
    I wrote comment for parameters definition (like /** @param string $xxxx ….*/ ), tip baloon show me what parameters are defined, but “smart function parameter” seems not care about it.

    Mainly I am using mysql database, and values for function parameters are use to saved in array( result of mysqli_fetch_assoc() ). Suggesting by type or name of variable is not effective in this case.

    For Example, like below.
    ————————- class file
    public class A{
    * @param string $first
    * @param string $second
    * @param string $third
    public function foo( $value1, $value2, $value3 )
    … some process…

    ————————- end

    ————————- html page file
    $clazz = new A();

    $clazz ->foo( $value1, $value2, $value3 ); ★
    ————————- end

    There are some problems in my case while writing last line.(★makred)
    1. smart function parameters insert nothing.
    2. $value1,2,3 is not suggested(type is blank) until cast to sring like (string) $array[“key1”] .
    -> casting is not difficult. but no suggestion available for use $array[“key1”] directly.
    I just want know what parameters are needed, and auto complete it.
    3. Only tip balloon shows me once what parameters are needed just after doing auto complition function name.
    I think that it is very helpful feature “just insert same parameters of function definition line”.

    Can I do it?

    Thank you for reading.

    • Artem Khvastunov

      Sorry that it took so long to reply. Most probably the type of $array is not known to PhpStorm. Simple hint could help: /** @var string[] $array */.

  • Pavel T

    It’s a great, but how can i make parameters tooltip to not hide after parameters was inserted? Like in the examples in the post. Here is my behavior (gif):