php: wrapping arguments in functions
Hi everyone,
Is it possible to have phpstorm "wrap" og "Surround With..." arguments in ex. if statements? Like this:
if($argument) -> have it surround with ex. empty function call if(!empty($argument)) by doing something like this if($argument.empty) and hitting tab.
Kind regards
René Petersen
请先登录再写评论。
Hi there,
>by doing something like this if($argument.empty) and hitting tab.
That's called Postfix code completion and unfortunately there is no template for your case ATM.
Consider watching those tickets (star/vote/comment) to get notified on any progress. You may ask for such postfix to be added in first ticket .. or maybe better -- create your own ticket (otherwise comments may get lost).
>ex. empty function call if(!empty($argument))
Right now you can do something like this via Intention quick fix (Alt+Enter on Windows/Linux .. or light bulb icon) .. but it has to be on variable itself. E.g.
(have caret placed somewhere on variable name; invoke Quick Fix menu, choose the right option)
It will become
if (!empty(argument)) {}
As you can see -- it is not suitable for your case where variable is already located inside if condition (if you use it you will get nested if inside if condition).
----
The only working solution for now for your case is to create and use custom Live Template:
-----
P.S.
empty() is not a function but language construct -- http://php.net/manual/en/reserved.keywords.php