On Wed, Dec 23, 2020 at 7:44 PM Ben Ramsey <b...@benramsey.com> wrote:

> I actually like the idea of flags added to `is_array()` for this.
>
> Something like:
>
>     is_array($value, ZERO_INDEXED | ASSOCIATIVE | INTEGER_INDEXED)
>

For static analysis, though, unary predicate (e.g. `is_list()`) is much
easier to work with, secondary only to actual type. Flags may lead to
indirection, such as (contrived example)

```php
class C {
   const FLAGS = ZERO_INDEXED | ASSOCIATIVE;
   private function getFlags(): int {
       return static::FLAGS;
   }

  public function foo(array $array): void {
      if (is_array($array, $this->getFlags())) { ... }
  }
```

-- 
  Best regards,
      Bruce Weirdan                                     mailto:
weir...@gmail.com

Reply via email to