On 25 October 2017 22:52:37 BST, Dan Ackroyd <dan...@basereality.com> wrote: >Although 'array of' as well as full blown generics are popular ideas, >I'm pretty certain the RFC failed due to the type check on the array >happening every time the 'array of' was passed from one function to >another, which would make it too slow to actually use.
The fundamental problem with extending PHP's type declarations - either to more complex types, or to other code elements such as properties - is that they are currently always checked at run-time, not with a separate static analyser. It's notable that in Go, the runtime type checks are considered a "development only" option, and strongly discouraged in production code due to performance impact. I wrote about this a few months back here: http://rwec.co.uk/q/php-type-system One possibility if we do want to keep the current run-time approach is to cache type information against values (zvals) so subsequent checks become quicker. The problem is working out exactly what to store and when to invalidate it - if you append 42 to an array that passed int[] on the last check, the ideal would be for us to know the type is still valid. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php