As abdullam
mentioned in his comment, the shortcut that worked for me is
Shift + Alt + F.
(The accepted answer didn't work for me. I am using Visual Studio Code on a Mac. I couldn't find the extension mentioned above i.e ext install PHP Code Format.)