I would like to transform all "array(...)" notation in "[...]" in my project but I don't find a regex that work for all cases.
Do you have something that work for all cases (nested array, array on multiple lines, nested array on multiple lines)
Code | Inspect Code...
--- run it on your files. One of the inspections called "Traditional syntax array literal detected".
Alternatively just run that specific inspection only via Code | Run Inspection by Name...
Once done, you will see a list with results. Find that particular inspection in results (in case if 1st option was used (all inspections)).
From there you can apply "Fix it" action on all (or individual) results of that inspection.
P.S. This inspection/fix available since PhpStorm v7.1.
Open File->Settings... Click Editor->Code Style->PHP->Code Conversion
Now you can find block "Array declaration style" at the bottom.
If you check checkbox "Force short declaration style" your "array(...)" became "[...]" when you run Reformat code (Ctrl+Shift+L).
As of now (PHPStorm 2017.3.2) it is here:
Settings/Editor/Code Style/PHP/Code Conversion/Array Declaration style
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With