This tool is designed to beautify PHP code, applying most of the PEAR standard requirements to it. It can even process really scrambled scripts, e.g. all code in one line, and thus may help you to get scripts into a more readable form.
T. Omori, and K. Maruyama. MSR '08: Proceedings of the 2008 international workshop on Mining software repositories, page 31--34. New York, NY, USA, ACM, (May 2008)