Hi Ben/Josh,

> I actually like the idea of flags added to `is_array()` for this.
>
> Something like:
> 
>     is_array($value, ZERO_INDEXED | ASSOCIATIVE | INTEGER_INDEXED)
>
> I’m not suggesting these names; they’re for illustration only.

I'm strongly opposed to adding any flags to is_array - keeping basic type 
checks simple would help in learning/reading/remembering the language,
has a small impact on performance for calls that aren't unambiguously qualified 
(especially if using both), and it makes it harder to see issues like
`is_array(really_long_multiline_call(arg1, arg2, ZERO_INDEXED))`

An idea for a PECL would be `pecl_check_type($value, 
PREFIX_MAY_BE_ARRAY|PREFIX_MAY_BE_ARRAY_KEY_LONG|PREFIX_MAY_BE_ARRAY_OF_STRING|PREFIX_MAY_BE_ARRAY_OF_OBJECT)`
to check for an array with integer keys and strings and objects as values, but 
I really can't imagine it getting adopted or being the main performance 
bottleneck in a typical php application, especially with the jit and with most 
arrays being small. (I don't have any interest in actually doing that)

Cheers,
Tyson



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to