The code style in PhpStorm has been doing strange things to my array indentation. When creating a new array in a normal way
$array = [|] // The | marks my cursor
Then I press enter
$array = [
| // My cursor starts all the way there
]
When I reformat my code using CMD+ALT+K, the indentation is reset.
$array = [
| // To here
]
This happens in every file in my project. I have checked my code style preferences, I have set them to PSR1/PSR2 standard, and have checked every single option that has something to do with indentation/arrays.
This only happens to arrays, not to function declarations, class declarations and control structures.
Is anyone familiar with this problem and if so, is there a solution?
Try this:
1.Go to Preferences -> Code Style -> PHP -> Set from... -> Predefined Style -> allows you to set your code style guidelines to the styles such as PSR-2 and Zend.
2.Go to Code -> Reformat Code -> This option will format all of your code to the code style you set. We recently converted our codebase of around 300,000 lines to the PSR-2 standard. It was done in less than 5 minutes.
Hope this helps. :)
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