views:

438

answers:

5

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 )

+1  A: 

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)

Yacoby
A: 

Well for a quick solution Aptana IDE does support a code format option

Phill Pafford
+1  A: 

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.

André Hoffmann
+1  A: 

Eclipse PDT also can format your code. Not sure how configurable it is. Just hit CTRL-Shift-F.

christian studer
A: 

See the SD PHP Formatter for a tool that prettyprints source files, one at a time, or in large batches, according to your preferred style.

Ira Baxter