Skip to content

Commit 7c8c3d7

Browse files
committed
Logger: added typehints
1 parent 8045973 commit 7c8c3d7

1 file changed

Lines changed: 13 additions & 24 deletions

File tree

src/Tracy/Logger/Logger.php

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,22 @@
1818
*/
1919
class Logger implements ILogger
2020
{
21-
/** @var ?string name of the directory where errors should be logged */
22-
public $directory;
21+
/** name of the directory where errors should be logged */
22+
public ?string $directory = null;
2323

24-
/** @var string|string[]|null email or emails to which send error notifications */
25-
public $email;
24+
/** email or emails to which send error notifications */
25+
public string|array|null $email = null;
2626

27-
/** @var ?string sender of email notifications */
28-
public $fromEmail;
27+
/** sender of email notifications */
28+
public ?string $fromEmail = null;
2929

30-
/** @var mixed interval for sending email is 2 days */
31-
public $emailSnooze = '2 days';
30+
/** interval for sending email is 2 days */
31+
public mixed $emailSnooze = '2 days';
3232

3333
/** @var callable(mixed $message, string $email): void handler for sending emails */
3434
public $mailer;
3535

36-
/** @var ?BlueScreen */
37-
private $blueScreen;
36+
private ?BlueScreen $blueScreen = null;
3837

3938

4039
/**
@@ -84,10 +83,7 @@ public function log(mixed $message, string $level = self::INFO)
8483
}
8584

8685

87-
/**
88-
* @param mixed $message
89-
*/
90-
public static function formatMessage($message): string
86+
public static function formatMessage(mixed $message): string
9187
{
9288
if ($message instanceof \Throwable) {
9389
$tmp = [];
@@ -108,10 +104,7 @@ public static function formatMessage($message): string
108104
}
109105

110106

111-
/**
112-
* @param mixed $message
113-
*/
114-
public static function formatLogLine($message, ?string $exceptionFile = null): string
107+
public static function formatLogLine(mixed $message, ?string $exceptionFile = null): string
115108
{
116109
return implode(' ', [
117110
date('[Y-m-d H-i-s]'),
@@ -160,10 +153,7 @@ protected function logException(\Throwable $exception, ?string $file = null): st
160153
}
161154

162155

163-
/**
164-
* @param mixed $message
165-
*/
166-
protected function sendEmail($message): void
156+
protected function sendEmail(mixed $message): void
167157
{
168158
$snooze = is_numeric($this->emailSnooze)
169159
? $this->emailSnooze
@@ -182,10 +172,9 @@ protected function sendEmail($message): void
182172

183173
/**
184174
* Default mailer.
185-
* @param mixed $message
186175
* @internal
187176
*/
188-
public function defaultMailer($message, string $email): void
177+
private function defaultMailer(mixed $message, string $email): void
189178
{
190179
$host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n'));
191180
mail(

0 commit comments

Comments
 (0)