Hold on, we are talking php here. There is no code compiling.
Either way what you are describing sounds like instead of maintaining sql code you prefer maintaining orm code. DTOs are just overhead.
I gave up on all these after 15 years of using them because the benefits are precisely zero (except for migrations). Similarly with typescript, if you are competent enough with js and as a programmer you dont need it. The web can overkill itself perfectly fine without a scripted language that transpiles to a scripted language.
Perhaps its just me, i rarely make typos and when i do the linter or ide catches them early on. In highschool they made us keep track of variables and their types with pen and paper and as a result i always know what type my var is. I was also taught that just because you can it doesnt mean you should. So i dont write a dto for transferring an object to a different api. It’s just a waste of time, specific to PHP devs.
Edit: the type of code you pasted is horrible to maintain. You can achieve that with less sql.