Skip to content

Commit 6273fec

Browse files
committed
Logger: added typehints
1 parent 1a1be93 commit 6273fec

File tree

1 file changed

+13
-24
lines changed

1 file changed

+13
-24
lines changed

src/Tracy/Logger/Logger.php

+13-24
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,22 @@
1515
*/
1616
class Logger implements ILogger
1717
{
18-
/** @var string|null name of the directory where errors should be logged */
19-
public $directory;
18+
/** name of the directory where errors should be logged */
19+
public ?string $directory = null;
2020

21-
/** @var string|array|null email or emails to which send error notifications */
22-
public $email;
21+
/** email or emails to which send error notifications */
22+
public string|array|null $email = null;
2323

24-
/** @var string|null sender of email notifications */
25-
public $fromEmail;
24+
/** sender of email notifications */
25+
public ?string $fromEmail = null;
2626

27-
/** @var mixed interval for sending email is 2 days */
28-
public $emailSnooze = '2 days';
27+
/** interval for sending email is 2 days */
28+
public mixed $emailSnooze = '2 days';
2929

3030
/** @var callable handler for sending emails */
3131
public $mailer;
3232

33-
/** @var BlueScreen|null */
34-
private $blueScreen;
33+
private ?BlueScreen $blueScreen = null;
3534

3635

3736
public function __construct(?string $directory, string|array|null $email = null, ?BlueScreen $blueScreen = null)
@@ -78,10 +77,7 @@ public function log(mixed $message, string $level = self::INFO)
7877
}
7978

8079

81-
/**
82-
* @param mixed $message
83-
*/
84-
public static function formatMessage($message): string
80+
public static function formatMessage(mixed $message): string
8581
{
8682
if ($message instanceof \Throwable) {
8783
foreach (Helpers::getExceptionChain($message) as $exception) {
@@ -101,10 +97,7 @@ public static function formatMessage($message): string
10197
}
10298

10399

104-
/**
105-
* @param mixed $message
106-
*/
107-
public static function formatLogLine($message, ?string $exceptionFile = null): string
100+
public static function formatLogLine(mixed $message, ?string $exceptionFile = null): string
108101
{
109102
return implode(' ', [
110103
date('[Y-m-d H-i-s]'),
@@ -152,10 +145,7 @@ protected function logException(\Throwable $exception, ?string $file = null): st
152145
}
153146

154147

155-
/**
156-
* @param mixed $message
157-
*/
158-
protected function sendEmail($message): void
148+
protected function sendEmail(mixed $message): void
159149
{
160150
$snooze = is_numeric($this->emailSnooze)
161151
? $this->emailSnooze
@@ -174,10 +164,9 @@ protected function sendEmail($message): void
174164

175165
/**
176166
* Default mailer.
177-
* @param mixed $message
178167
* @internal
179168
*/
180-
public function defaultMailer($message, string $email): void
169+
public function defaultMailer(mixed $message, string $email): void
181170
{
182171
$host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n'));
183172
$parts = str_replace(

0 commit comments

Comments
 (0)