Anonymous Class

A class may be instantiated, without defining a class name. The class is identical to a named-class, except for the name attribute. This also means that it cannot be used for typing, though it may be typed itself, using parent class or implemented interfaces.

Also, arguments may be passed at instantiation time, unlike with named-class definition, where those arguments are passed when calling new, not when defining the class.

<?php
     interface i {}
     function foo(i $a) {}

     $a = new class () implements i {};

     foo($a);
?>

Documentation

See also PHP Anonymous Class, PHP 7.0 - Anonymous Classes

Related : Closure