From 12e5e7747eecd74313bbfc51dbb5fc75569c5146 Mon Sep 17 00:00:00 2001 From: Arkadius Jonczek Date: Fri, 13 Sep 2019 23:26:53 +0200 Subject: [PATCH] add trait example to php language --- languages/php.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/languages/php.php b/languages/php.php index 78a565f..572cf93 100644 --- a/languages/php.php +++ b/languages/php.php @@ -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; +} \ No newline at end of file