Anonymous classes in PHP 7

Code
<?php

use Psr\Log\{AbstractLoggerLoggerInterfaceLoggerAwareInterface};

$logger = new class($value) extends AbstractLogger {
    public function 
log($level$message, array $context = array())
    {
        
$msg sprintf('[%s] %s'$level$message);
        
        if (
$context) {
            
$search array_keys($context);
            
array_walk($search, function(&$value$key) {
                
$value sprintf('{%s}'$value);
            });
            
$replace array_values($context);
        
            
$msg str_replace($search$replace$msg);
        }
        
        echo 
$msg PHP_EOL;
    }
};

$object = new class implements LoggerAwareInterface {
    private 
$logger;
    
    public function 
setLogger(LoggerInterface $logger)
    {
        
$this->logger $logger;
    }
    
    public function 
run()
    {
        if (
null !== $this->logger) {
            
$this->logger->error('an error happened in {file}', array('file' => 'foo.php'));
            
$this->logger->notice('{reason} happened, but I work anyway', array('reason' => 'stuff'));
        }
        
        return 
0;
    }
};

$object->setLogger($logger);
$object->run();
Result
[error] an error happened in foo.php
[notice] stuff happened, but I work anyway
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6