I'm working with websites written in PHP, along with many other programmers, and sometimes I have to deal with really awful code.
Indentation totally messed up, curly braces in the wrong places, terrible whitespace use, it really hurts my eyes and actually makes my work harder and take longer.
Is there a tool where you can specify your coding style and then it applies it to files? I'm sure there must be such functions in different IDEs, but I need an independent tool as I code with simple notepads like Notepad++ or the like. ( if it's such a function in Notepad++, I didn't see it )
Use an EditorConfig file when you want to enforce coding styles for all contributors to your repo or project. You can manually populate your EditorConfig file, or you can automatically generate the file based on the code style settings you've chosen in the Visual Studio Options dialog box.
"Code Cleanup is a new feature of Visual Studio 2019 that will automatically clean up your code file to make sure it is formatted correctly and that your coding style preferences are applied," the marketplace description says.
To access this options page, choose Tools > Options from the menu bar. In the Options dialog box, choose Text Editor > C# > Code Style > Formatting.
Try PHP Code Sniffer.
That should be exactly what you are looking for(at least that's what I thought afert reading the heading, see the update).
UPDATE: Actually what Code Sniffer does is go through your code and detect coding style violations, it does not however fix the problems.
But by telling you what's wrong it enforces you to adhere to a certain coding style. So that might be an option for you in the future.
While I have never used any, as I (luckly?) don't use anyone else code much, google found this, PHP Beautifier.
EDIT
See this question which recommends PHP Code Beautifier which is free (but requires an account creation)
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