1616 */
1717class Logger implements ILogger
1818{
19- /** @var ?string name of the directory where errors should be logged */
20- public $ directory ;
19+ /** name of the directory where errors should be logged */
20+ public ? string $ directory = null ;
2121
22- /** @var string|string[]|null email or emails to which send error notifications */
23- public $ email ;
22+ /** @var string|string[]|null email or emails to which send error notifications */
23+ public string | array | null $ email = null ;
2424
25- /** @var ?string sender of email notifications */
26- public $ fromEmail ;
25+ /** sender of email notifications */
26+ public ? string $ fromEmail = null ;
2727
28- /** @var string|int interval for sending email is 2 days */
29- public $ emailSnooze = '2 days ' ;
28+ /** interval for sending email is 2 days */
29+ public string | int $ emailSnooze = '2 days ' ;
3030
31- /** @var callable (mixed $message, string $email): void handler for sending emails */
32- public $ mailer ;
31+ /** @var \Closure (mixed $message, string $email): void handler for sending emails */
32+ public ? \ Closure $ mailer = null ;
3333
34- /** @var ?BlueScreen */
35- private $ blueScreen ;
34+ private ?BlueScreen $ blueScreen = null ;
3635
3736
3837 /**
@@ -52,7 +51,7 @@ public function __construct(?string $directory, string|array|null $email = null,
5251 * For levels ERROR, EXCEPTION and CRITICAL it sends email.
5352 * @return ?string logged error filename
5453 */
55- public function log (mixed $ message , string $ level = self ::INFO )
54+ public function log (mixed $ message , string $ level = self ::INFO ): ? string
5655 {
5756 if (!$ this ->directory ) {
5857 throw new \LogicException ('Logging directory is not specified. ' );
@@ -82,10 +81,7 @@ public function log(mixed $message, string $level = self::INFO)
8281 }
8382
8483
85- /**
86- * @param mixed $message
87- */
88- public static function formatMessage ($ message ): string
84+ public static function formatMessage (mixed $ message ): string
8985 {
9086 if ($ message instanceof \Throwable) {
9187 $ tmp = [];
@@ -106,10 +102,7 @@ public static function formatMessage($message): string
106102 }
107103
108104
109- /**
110- * @param mixed $message
111- */
112- public static function formatLogLine ($ message , ?string $ exceptionFile = null ): string
105+ public static function formatLogLine (mixed $ message , ?string $ exceptionFile = null ): string
113106 {
114107 return implode (' ' , [
115108 date ('[Y-m-d H-i-s] ' ),
@@ -159,10 +152,7 @@ protected function logException(\Throwable $exception, ?string $file = null): st
159152 }
160153
161154
162- /**
163- * @param mixed $message
164- */
165- protected function sendEmail ($ message ): void
155+ protected function sendEmail (mixed $ message ): void
166156 {
167157 $ snooze = is_numeric ($ this ->emailSnooze )
168158 ? $ this ->emailSnooze
@@ -179,12 +169,7 @@ protected function sendEmail($message): void
179169 }
180170
181171
182- /**
183- * Default mailer.
184- * @param mixed $message
185- * @internal
186- */
187- public function defaultMailer ($ message , string $ email ): void
172+ private function defaultMailer (mixed $ message , string $ email ): void
188173 {
189174 $ host = preg_replace ('#[^\w.-]+# ' , '' , $ _SERVER ['SERVER_NAME ' ] ?? php_uname ('n ' ));
190175 mail (
0 commit comments