4 ms·
PHP's strict typing is only enforced at runtime, and because of that, its type system is very simple, unlike Typescript's. You can enforce that a variable is an
by duckerude 6y ago
PHP's strict typing is only enforced at runtime, and because of that, its type system is very simple, unlike Typescript's. You can enforce that a variable is an array, but not that it's an array of ints, let alone that it's an array with certain types under certain keys.
Although there is external tooling that uses static analysis for such more complicated types.
- xellisx 6y agoWe really need structs in PHP. I drew up a draft, but didn't get very far with it. https://github.com/ellisgl/PHP-RFC-Struct-Data-Type https://github.com/ellisgl/PHP-RFC-Struct-Data-Type