Rather PHP related question

Sorry for spamming here, I’m working on the REST API based on Slim 4 framework, which interacts with JS based fronted. When I tried to move some calculation related tasks from Slim backend to frontend I realized that all queries I do against the PgSQL database using PDO returns only strings regardless of database data type. Any suggestions how for elegant typecasting back to original data types?

Mostly interested how to work with float data type.

As far as I know in PHP 8.1 integers and floats of the PDO result sets will be returned as native PHP types, instead of strings. See here.

Edit: This applies only for Sqlite, but not for PgSql. I think you have to cast it manually or with a library like this.