iterator_count() Also Count Arrays

The PHP native function used to accept only iterators. Since PHP 8.1, arrays are also welcomed.

PHP code

<?php

print iterator_count([1,2,3]);

?>

Before

Uncaught TypeError: iterator_count(): Argument #1 ($iterator) must be of type Traversable, array given

After

3

PHP version change

This behavior changed in 8.2

Error Messages