How to set MYSQLI_OPT_INT_AND_FLOAT_NATIVE option

That’s why I’m wondering why is WordPress stuck to this pre-PHP-5.3
limitation.

Because WordPress has made the decision to support PHP 5.2 due to the large number of hosts that continue to use it. This is an ongoing debate and there’s no point rehashing it all here.

But this means that I have to know in advance each end every data type returned from the MYSQL query, which is by far an anti-pattern programming technique.

What? MySQL in PHP, by default, only returns strings. So there you go. That’s “each and every data type” that you need to know.

Regardless, you should know what your query is likely to return before outputting it to a page. And you should be verifying and escaping it before outputting it in the browser or an API response.

Most things like this have some sort of model that represents the data that sits between the front-end and the database. What is an anti-pattern is having your front-end so tightly coupled to the minutiae of how the data is stored.