array to []

Hi Folks,

How to convert automatically all "array" to short syntax [ ] in the current file in PhpStorm.

Thanks.

4 comments
Comment actions Permalink

wonder what that means.....


0
Comment actions Permalink

array-to-short.png
I migrate current project from PHP 5.2 to 5.5 and would like to use short array syntax. There are >100 arrays in current file, see screenshort. It is time-consuming to click "Convert to short syntax" for each array. Yes, I can leave array as is for old codes and use a new syntax for new code. However, it would be nice if PhpStorm allow to convert all arrays to a new syntax in "one click" for whole opened file or for all files in project. Thanks.

0
Comment actions Permalink

Tried a few things with recording macros (under 'Edit') but couldn't find anything that worked real well.

Give that a go perhaps.

The closest thing to success (depending on how much code you have though) is to use F3 (find next) and alt+enter


So to run through a file it would be
* cursor on the first 'array('
* alt+enter
* enter
* F3
* alt+enter
* enter
* F3
* alt+enter
* enter
* F3
....

It would be nice if that could be recorded to a macro, but it didn't seam to work with 'Intentions'  and I couldn't see a way to assign a keyboard shortcut to an intention.

0

Please sign in to leave a comment.