WordPress core is pretty wild. But modern WordPress isn’t working purely in that. The latest WP uses PHP primarily as a backend, and modern JS as a frontend and passing data through filters->DB.
I won’t call it elegant. But it’s not the PHP experience from five years ago.