Prettier is a great code beautifier for PHP, once you get it to work.
https://github.com/prettier/plugin-php
On Arch Linux, PHP 8.2
npm install --global prettier @prettier/plugin-php
usage: prettier test.php
But all I could get was
[error] No parser could be inferred for file "test.php"
After a lot of fiddling and swearing, I solved it by creating ~/.prettierrc
{
"plugins": ["/usr/local/lib/node_modules/@prettier/plugin-php/src/index.js"]
}