In this comment, andreas.braun pointed out that PHP 8's get_debug_type can be used to replace the following:
is_object($expected) ? get_class($expected) : gettype($expected);
The above code is used throughout the library and its test suite. For earlier versions of PHP, we can rely on symfony/polyfill.