The «Changelog» section of the PHP count() function specification says:
| Version | Description |
|---|---|
| 7.2.0 |
count() will now yield a warning on invalid countable types passed to the array_or_countable parameter. |

http://php.net/manual/en/function.count.php#refsect1-function.count-changelog