A slight correction on the answer based on Code reformatting on save in PhpStorm or other jetbrains ide This answer is basically correct, but you need to create a custom keybinding for Save All in order for it to work, and the keybinding given for Windows (or Linux), Ctrl+Alt+S is used to open the settings dialog which could have unwanted consequences.
Change the Save All key binding
Open the settings with ctrl +alt+s (Windows/Linux) or cmd++ (Mac).
Go to Keymap -> Main Menu -> File->Save All
Right click and select Remove Ctrl+S/Cmd+S
Right click and select Add Keyboard Shortcut
Set keyboard shortcut to Ctrl+Alt+Shift+S (Windows/Linux) or Cmd+Alt+Shift+S (Mac) and click OK on the shortcut window and settings window.
Create the Macro
Click on Edit -> Macros -> Start Macro Recording
Press Ctrl+Alt+l then Ctrl+Alt+Shift+S (Windows/Linux) or Cmd+Alt+l and Cmd+Alt+Shift+S (Mac)
Enter a name such as Format-save
Setting the keybinding
Open the settings with ctrl +alt+s (Windows/Linux) or cmd++ (Mac).
Go to Keymap -> Main Menu -> Edit->Macros->Format-save
Right click and select Add Keyboard Shortcut
Enter ctrl +s (Windows/Linux) or cmd+s (Mac) and click OK on the shortcut window and settings window.