Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

Commit 9f6056a

Browse files
felixuref3l1x
authored andcommitted
Source: add PHP 8.2 native type hints, fix coding style
1 parent 181e503 commit 9f6056a

18 files changed

Lines changed: 48 additions & 81 deletions

src/AbstractLogger.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
abstract class AbstractLogger implements ILogger
1212
{
1313

14-
/** @var string */
15-
protected $directory;
14+
protected string $directory;
1615

1716
public function __construct(string $directory)
1817
{

src/BlueScreenFileLogger.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@
1515
class BlueScreenFileLogger extends AbstractLogger implements ILogger
1616
{
1717

18-
/** @var BlueScreen|null */
19-
private $blueScreen;
18+
private ?BlueScreen $blueScreen = null;
2019

2120
public function __construct(string $directory, ?BlueScreen $blueScreen = null)
2221
{
2322
parent::__construct($directory);
23+
2424
$this->blueScreen = $blueScreen;
2525
}
2626

27-
/**
28-
* @param mixed $message
29-
*/
30-
public function log($message, string $priority = ILogger::INFO): void
27+
public function log(mixed $message, string $priority = ILogger::INFO): void
3128
{
3229
if (!is_dir($this->directory)) {
3330
throw new InvalidStateException('Directory ' . $this->directory . ' is not found or is not directory.');

src/Exceptions/Runtime/Logger/SlackBadRequestException.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ final class SlackBadRequestException extends RuntimeException
88
{
99

1010
/** @var mixed[] */
11-
private $request;
11+
private array $request;
1212

1313
/**
1414
* @param mixed[] $request
1515
*/
1616
public function __construct(array $request)
1717
{
1818
parent::__construct();
19+
1920
$this->request = $request;
2021
}
2122

src/FileLogger.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
class FileLogger extends AbstractLogger implements ILogger
1515
{
1616

17-
/**
18-
* @param mixed $message
19-
*/
20-
public function log($message, string $priority = ILogger::INFO): void
17+
public function log(mixed $message, string $priority = ILogger::INFO): void
2118
{
2219
if (!is_dir($this->directory)) {
2320
throw new InvalidStateException('Directory "' . $this->directory . '" is not found or is not directory.');

src/ILogger.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ interface ILogger
1414
public const EXCEPTION = TracyLogger::EXCEPTION;
1515
public const CRITICAL = TracyLogger::CRITICAL;
1616

17-
/**
18-
* @param mixed $message
19-
*/
20-
public function log($message, string $priority = ILogger::INFO): void;
17+
public function log(mixed $message, string $priority = ILogger::INFO): void;
2118

2219
}

src/Mailer/FileMailer.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@
88
class FileMailer implements IMailer
99
{
1010

11-
/** @var string */
12-
private $directory;
11+
private string $directory;
1312

1413
public function __construct(string $directory)
1514
{
1615
$this->directory = $directory;
1716
}
1817

19-
/**
20-
* @param mixed $message
21-
*/
22-
public function send($message): void
18+
public function send(mixed $message): void
2319
{
2420
/** @var string $host */
2521
$host = preg_replace('#[^\w.-]+#', '', $_SERVER['HTTP_HOST'] ?? php_uname('n'));

src/Mailer/IMailer.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
interface IMailer
66
{
77

8-
/**
9-
* @param mixed $message
10-
*/
11-
public function send($message): void;
8+
public function send(mixed $message): void;
129

1310
}

src/Mailer/TracyMailer.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111
class TracyMailer implements IMailer
1212
{
1313

14-
/** @var string|null */
15-
private $from;
14+
private ?string $from = null;
1615

1716
/** @var mixed[] */
18-
private $to = [];
17+
private array $to = [];
1918

2019
/**
2120
* @param mixed[] $to
@@ -26,10 +25,7 @@ public function __construct(?string $from, array $to)
2625
$this->to = $to;
2726
}
2827

29-
/**
30-
* @param mixed $message
31-
*/
32-
public function send($message): void
28+
public function send(mixed $message): void
3329
{
3430
/** @var string $host */
3531
$host = preg_replace('#[^\w.-]+#', '', $_SERVER['HTTP_HOST'] ?? php_uname('n'));

src/SendMailLogger.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
class SendMailLogger extends AbstractLogger
99
{
1010

11-
/** @var string */
12-
private $emailSnooze = '2 days';
11+
private string $emailSnooze = '2 days';
1312

14-
/** @var IMailer */
15-
private $mailer;
13+
private IMailer $mailer;
1614

1715
/** @var string[] */
18-
private $allowedPriority = [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL];
16+
private array $allowedPriority = [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL];
1917

2018
public function __construct(IMailer $mailer, string $directory)
2119
{
2220
parent::__construct($directory);
21+
2322
$this->mailer = $mailer;
2423
}
2524

@@ -41,10 +40,7 @@ public function setMailer(IMailer $mailer): void
4140
$this->mailer = $mailer;
4241
}
4342

44-
/**
45-
* @param mixed $message
46-
*/
47-
public function log($message, string $priority = ILogger::INFO): void
43+
public function log(mixed $message, string $priority = ILogger::INFO): void
4844
{
4945
if (!in_array($priority, $this->allowedPriority, true)) {
5046
return;

src/Sentry/SentryLogger.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class SentryLogger implements ILogger
2626
public const CONFIG_OPTIONS = 'options';
2727

2828
/** @var mixed[] */
29-
protected $configuration;
29+
protected array $configuration;
3030

3131
/** @var string[] */
32-
private $allowedPriority = [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL];
32+
private array $allowedPriority = [ILogger::ERROR, ILogger::EXCEPTION, ILogger::CRITICAL];
3333

3434
/**
3535
* @param mixed[] $configuration
@@ -58,9 +58,8 @@ public function setAllowedPriority(array $allowedPriority): void
5858
/**
5959
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
6060
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint
61-
* @param mixed $message
6261
*/
63-
public function log($message, string $priority = ILogger::INFO): void
62+
public function log(mixed $message, string $priority = ILogger::INFO): void
6463
{
6564
if (!in_array($priority, $this->allowedPriority, true)) {
6665
return;
@@ -77,10 +76,7 @@ public function log($message, string $priority = ILogger::INFO): void
7776
$this->makeRequest($message, $scope);
7877
}
7978

80-
/**
81-
* @param mixed $message
82-
*/
83-
protected function makeRequest($message, Scope $scope): void
79+
protected function makeRequest(mixed $message, Scope $scope): void
8480
{
8581
$client = ClientBuilder::create($this->configuration[self::CONFIG_OPTIONS] + ['dsn' => $this->configuration[self::CONFIG_URL]])
8682
->getClient();

0 commit comments

Comments
 (0)