Matthieu Napoli, author of PHP-DI and externals.io, wrote a post on how you can use anonymous classes to quickly create mocks, spies and fixtures.

Anonymous classes were added to PHP 7. This article intends to show how useful they can be for writing tests.

http://mnapoli.fr/anonymous-classes-in-tests/