1--TEST--
2Test is_countable() function
3--CREDITS--
4Gabriel Caruso (carusogabriel34@gmail.com)
5--FILE--
6<?php
7var_dump(is_countable([1, 2, 3]));
8var_dump(is_countable((array) 1));
9var_dump(is_countable((object) ['foo', 'bar', 'baz']));
10
11$foo = ['', []];
12
13if (is_countable($foo)) {
14    var_dump(count($foo));
15}
16
17$bar = null;
18if (!is_countable($bar)) {
19    try {
20        count($bar);
21    } catch (\TypeError $e) {
22        echo $e->getMessage() . \PHP_EOL;
23    }
24}
25?>
26--EXPECT--
27bool(true)
28bool(true)
29bool(false)
30int(2)
31count(): Argument #1 ($value) must be of type Countable|array, null given
32