Highlight (left click, drag, left release) the lines you want to format, and press Ctrl + Shift + F, or right click and select Source -> Format
.
For Java code, you have to highlight a complete piece of code (statement(s), method).
For PHP, I imagine you would still have to highlight a complete piece of code.
Tested on Windows version of Eclipse 4.2.