add trait example to php language

This commit is contained in:
Arkadius Jonczek 2019-09-13 23:26:53 +02:00
parent d9eee18d87
commit 12e5e7747e
1 changed files with 36 additions and 0 deletions

View File

@ -303,3 +303,39 @@ abstract class AbstractClassName
abstract function abstractFunction(Type $var = null): Type;
}
/**
* Basic Implementation of LoggerAwareInterface.
* @see https://github.com/php-fig/log/blob/master/Psr/Log/LoggerAwareTrait.php
*/
trait LoggerAwareTrait
{
/**
* The logger instance.
*
* @var LoggerInterface
*/
protected $logger;
/**
* Sets a logger.
*
* @param LoggerInterface $logger
*/
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
}
}
/**
* Example with use of LoggerAwareTrait.
*/
class ClassWithLogger
{
/**
* Use the LoggerAwareTrait in this class.
*/
use LoggerAwareTrait;
}