Again in a rush to fix my code to stick with PSR2 coding standards I’ve met another fix PHP Code Sniffer Fixer does not catch up with: curly braces should always be on new lines after class and functions declarations.
The regex pattern to use in Sublime Text Find and Replace
function is an easy one [caption id=“attachment_550” align=“aligncenter” width=“832”] Almighty search and replace[/caption] In string terms this is the string to find
^(\s*(interface|class|abstract|public|static|private|protected).*?)\s*\{\s*$
and this is the string to replace it with
$1\v{
I’ve tested the regex on my code and it worked on multiple matches too and launching it more than one time on already properly formatted code should not add more blank lines.
The Find and Replace
function will not take care of indentation but that can be easily taken care of using Sublime Text re-indent
lines command or, if using Sublime Text in Vintage Mode
, using the
gg=G
command. Straight from vim
.