Skip to content

Commit 7e58925

Browse files
committed
added property typehints
1 parent afb7518 commit 7e58925

File tree

18 files changed

+138
-224
lines changed

18 files changed

+138
-224
lines changed

src/Bridges/Nette/MailSender.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ class MailSender
2020
{
2121
use Nette\SmartObject;
2222

23-
/** @var Nette\Mail\IMailer */
24-
private $mailer;
23+
private Nette\Mail\IMailer $mailer;
2524

2625
/** @var string|null sender of email notifications */
27-
private $fromEmail;
26+
private ?string $fromEmail = null;
2827

2928

3029
public function __construct(Nette\Mail\IMailer $mailer, ?string $fromEmail = null)

src/Bridges/Nette/TracyExtension.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ class TracyExtension extends Nette\DI\CompilerExtension
2121
{
2222
private const ErrorSeverityPattern = 'E_(?:ALL|PARSE|STRICT|RECOVERABLE_ERROR|(?:CORE|COMPILE)_(?:ERROR|WARNING)|(?:USER_)?(?:ERROR|WARNING|NOTICE|DEPRECATED))';
2323

24-
/** @var bool */
25-
private $debugMode;
26-
27-
/** @var bool */
28-
private $cliMode;
24+
private bool $debugMode;
25+
private bool $cliMode;
2926

3027

3128
public function __construct(bool $debugMode = false, bool $cliMode = false)

src/Bridges/Psr/PsrToTracyLoggerAdapter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class PsrToTracyLoggerAdapter implements Tracy\ILogger
2828
Tracy\ILogger::CRITICAL => Psr\Log\LogLevel::CRITICAL,
2929
];
3030

31-
/** @var Psr\Log\LoggerInterface */
32-
private $psrLogger;
31+
private Psr\Log\LoggerInterface $psrLogger;
3332

3433

3534
public function __construct(Psr\Log\LoggerInterface $psrLogger)

src/Bridges/Psr/TracyToPsrLoggerAdapter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class TracyToPsrLoggerAdapter extends Psr\Log\AbstractLogger
3030
Psr\Log\LogLevel::DEBUG => Tracy\ILogger::DEBUG,
3131
];
3232

33-
/** @var Tracy\ILogger */
34-
private $tracyLogger;
33+
private Tracy\ILogger $tracyLogger;
3534

3635

3736
public function __construct(Tracy\ILogger $tracyLogger)

src/Tracy/Bar/Bar.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
class Bar
1717
{
1818
/** @var IBarPanel[] */
19-
private $panels = [];
20-
21-
/** @var bool */
22-
private $loaderRendered = false;
19+
private array $panels = [];
20+
private bool $loaderRendered = false;
2321

2422

2523
/**

src/Tracy/BlueScreen/BlueScreen.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,40 +18,34 @@ class BlueScreen
1818
private const MaxMessageLength = 2000;
1919

2020
/** @var string[] */
21-
public $info = [];
21+
public array $info = [];
2222

2323
/** @var string[] paths to be collapsed in stack trace (e.g. core libraries) */
24-
public $collapsePaths = [];
24+
public array $collapsePaths = [];
2525

26-
/** @var int */
27-
public $maxDepth = 5;
26+
public int $maxDepth = 5;
2827

29-
/** @var int */
30-
public $maxLength = 150;
28+
public int $maxLength = 150;
3129

32-
/** @var int */
33-
public $maxItems = 100;
30+
public int $maxItems = 100;
3431

3532
/** @var callable|null a callable returning true for sensitive data; fn(string $key, mixed $val): bool */
3633
public $scrubber;
3734

3835
/** @var string[] */
39-
public $keysToHide = ['password', 'passwd', 'pass', 'pwd', 'creditcard', 'credit card', 'cc', 'pin', self::class . '::$snapshot'];
36+
public array $keysToHide = ['password', 'passwd', 'pass', 'pwd', 'creditcard', 'credit card', 'cc', 'pin', self::class . '::$snapshot'];
4037

41-
/** @var bool */
42-
public $showEnvironment = true;
38+
public bool $showEnvironment = true;
4339

4440
/** @var callable[] */
45-
private $panels = [];
41+
private array $panels = [];
4642

4743
/** @var callable[] functions that returns action for exceptions */
48-
private $actions = [];
44+
private array $actions = [];
4945

50-
/** @var callable[] */
51-
private $fileGenerators = [];
46+
private array $fileGenerators = [];
5247

53-
/** @var array */
54-
private $snapshot;
48+
private ?array $snapshot = null;
5549

5650

5751
public function __construct()

src/Tracy/Debugger/Debugger.php

Lines changed: 58 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -27,71 +27,70 @@ class Debugger
2727

2828
public const COOKIE_SECRET = 'tracy-debug';
2929

30-
/** @var bool in production mode is suppressed any debugging output */
31-
public static $productionMode = self::DETECT;
30+
/** in production mode is suppressed any debugging output */
31+
public static ?bool $productionMode = self::DETECT;
3232

33-
/** @var bool whether to display debug bar in development mode */
34-
public static $showBar = true;
33+
/** whether to display debug bar in development mode */
34+
public static bool $showBar = true;
3535

36-
/** @var int size of reserved memory */
37-
public static $reservedMemorySize = 500000;
36+
/** size of reserved memory */
37+
public static int $reservedMemorySize = 500000;
3838

39-
/** @var bool */
40-
private static $enabled = false;
39+
private static bool $enabled = false;
4140

42-
/** @var string|null reserved memory; also prevents double rendering */
43-
private static $reserved;
41+
/** reserved memory; also prevents double rendering */
42+
private static ?string $reserved = null;
4443

45-
/** @var int initial output buffer level */
46-
private static $obLevel;
44+
/** initial output buffer level */
45+
private static int $obLevel;
4746

48-
/** @var ?array output buffer status @internal */
49-
public static $obStatus;
47+
/** output buffer status @internal */
48+
public static ?array $obStatus = null;
5049

5150
/********************* errors and exceptions reporting ****************d*g**/
5251

53-
/** @var bool|int determines whether any error will cause immediate death in development mode; if integer that it's matched against error severity */
54-
public static $strictMode = false;
52+
/** determines whether any error will cause immediate death in development mode; if integer that it's matched against error severity */
53+
public static bool|int $strictMode = false;
5554

56-
/** @var bool|int disables the @ (shut-up) operator so that notices and warnings are no longer hidden; if integer than it's matched against error severity */
57-
public static $scream = false;
55+
/** disables the @ (shut-up) operator so that notices and warnings are no longer hidden; if integer than it's matched against error severity */
56+
public static bool|int $scream = false;
5857

5958
/** @var callable[] functions that are automatically called after fatal error */
60-
public static $onFatalError = [];
59+
public static array $onFatalError = [];
6160

6261
/********************* Debugger::dump() ****************d*g**/
6362

64-
/** @var int how many nested levels of array/object properties display by dump() */
65-
public static $maxDepth = 15;
63+
/** how many nested levels of array/object properties display by dump() */
64+
public static int $maxDepth = 15;
6665

67-
/** @var int how long strings display by dump() */
68-
public static $maxLength = 150;
66+
/** how long strings display by dump() */
67+
public static int $maxLength = 150;
6968

70-
/** @var int how many items in array/object display by dump() */
71-
public static $maxItems = 100;
69+
/** how many items in array/object display by dump() */
70+
public static int $maxItems = 100;
7271

73-
/** @var bool display location by dump()? */
74-
public static $showLocation;
72+
/** display location by dump()? */
73+
public static ?bool $showLocation = null;
7574

7675
/** @var string[] sensitive keys not displayed by dump() */
77-
public static $keysToHide = [];
76+
public static array $keysToHide = [];
7877

79-
/** @var string theme for dump() */
80-
public static $dumpTheme = 'light';
78+
/** theme for dump() */
79+
public static string $dumpTheme = 'light';
8180

8281
/** @deprecated */
8382
public static $maxLen;
8483

8584
/********************* logging ****************d*g**/
8685

87-
/** @var string|null name of the directory where errors should be logged */
88-
public static $logDirectory;
86+
/** name of the directory where errors should be logged */
87+
public static ?string $logDirectory = null;
8988

90-
/** @var int log bluescreen in production mode for this error severity */
91-
public static $logSeverity = 0;
89+
/** log bluescreen in production mode for this error severity */
90+
public static int $logSeverity = 0;
9291

93-
/** @var string|array email(s) to which send error notifications */
94-
public static $email;
92+
/** email(s) to which send error notifications */
93+
public static string|array|null $email = null;
9594

9695
/** for Debugger::log() */
9796
public const
@@ -104,49 +103,44 @@ class Debugger
104103

105104
/********************* misc ****************d*g**/
106105

107-
/** @var float timestamp with microseconds of the start of the request */
108-
public static $time;
106+
/** timestamp with microseconds of the start of the request */
107+
public static float $time;
109108

110-
/** @var string URI pattern mask to open editor */
111-
public static $editor = 'editor://%action/?file=%file&line=%line&search=%search&replace=%replace';
109+
/** URI pattern mask to open editor */
110+
public static ?string $editor = 'editor://%action/?file=%file&line=%line&search=%search&replace=%replace';
112111

113-
/** @var array replacements in path */
114-
public static $editorMapping = [];
112+
/** replacements in path */
113+
public static array $editorMapping = [];
115114

116-
/** @var string command to open browser (use 'start ""' in Windows) */
117-
public static $browser;
115+
/** command to open browser (use 'start ""' in Windows) */
116+
public static string $browser;
118117

119-
/** @var string custom static error template */
120-
public static $errorTemplate;
118+
/** custom static error template */
119+
public static ?string $errorTemplate = null;
121120

122121
/** @var string[] */
123-
public static $customCssFiles = [];
122+
public static array $customCssFiles = [];
124123

125124
/** @var string[] */
126-
public static $customJsFiles = [];
125+
public static array $customJsFiles = [];
127126

128127
/** @var callable[] */
129128
private static $sourceMappers = [];
130129

131-
/** @var array|null */
132-
private static $cpuUsage;
130+
private static ?array $cpuUsage = null;
133131

134132
/********************* services ****************d*g**/
135133

136-
/** @var BlueScreen */
137-
private static $blueScreen;
134+
private static BlueScreen $blueScreen;
138135

139-
/** @var Bar */
140-
private static $bar;
136+
private static Bar $bar;
141137

142-
/** @var ILogger */
143-
private static $logger;
138+
private static ILogger $logger;
144139

145140
/** @var array{DevelopmentStrategy, ProductionStrategy} */
146-
private static $strategy;
141+
private static array $strategy;
147142

148-
/** @var SessionStorage */
149-
private static $sessionStorage;
143+
private static SessionStorage $sessionStorage;
150144

151145

152146
/**
@@ -384,7 +378,7 @@ public static function removeOutputBuffers(bool $errorOccurred): void
384378

385379
public static function getBlueScreen(): BlueScreen
386380
{
387-
if (!self::$blueScreen) {
381+
if (empty(self::$blueScreen)) {
388382
self::$blueScreen = new BlueScreen;
389383
self::$blueScreen->info = [
390384
'PHP ' . PHP_VERSION,
@@ -399,7 +393,7 @@ public static function getBlueScreen(): BlueScreen
399393

400394
public static function getBar(): Bar
401395
{
402-
if (!self::$bar) {
396+
if (empty(self::$bar)) {
403397
self::$bar = new Bar;
404398
self::$bar->addPanel($info = new DefaultBarPanel('info'), 'Tracy:info');
405399
$info->cpuUsage = self::$cpuUsage;
@@ -418,7 +412,7 @@ public static function setLogger(ILogger $logger): void
418412

419413
public static function getLogger(): ILogger
420414
{
421-
if (!self::$logger) {
415+
if (empty(self::$logger)) {
422416
self::$logger = new Logger(self::$logDirectory, self::$email, self::getBlueScreen());
423417
self::$logger->directory = &self::$logDirectory; // back compatiblity
424418
self::$logger->email = &self::$email;
@@ -443,7 +437,7 @@ public static function getStrategy()
443437

444438
public static function setSessionStorage(SessionStorage $storage): void
445439
{
446-
if (self::$sessionStorage) {
440+
if (isset(self::$sessionStorage)) {
447441
throw new \Exception('Storage is already set.');
448442
}
449443

@@ -454,7 +448,7 @@ public static function setSessionStorage(SessionStorage $storage): void
454448
/** @internal */
455449
public static function getSessionStorage(): SessionStorage
456450
{
457-
if (!self::$sessionStorage) {
451+
if (empty(self::$sessionStorage)) {
458452
self::$sessionStorage = @is_dir($dir = session_save_path())
459453
|| @is_dir($dir = ini_get('upload_tmp_dir'))
460454
|| @is_dir($dir = sys_get_temp_dir())

src/Tracy/Debugger/DeferredContent.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@
1515
*/
1616
final class DeferredContent
1717
{
18-
/** @var SessionStorage */
19-
private $sessionStorage;
20-
21-
/** @var string */
22-
private $requestId;
23-
24-
/** @var bool */
25-
private $useSession = false;
18+
private SessionStorage $sessionStorage;
19+
private string $requestId;
20+
private bool $useSession = false;
2621

2722

2823
public function __construct(SessionStorage $sessionStorage)

src/Tracy/Debugger/DevelopmentStrategy.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717
*/
1818
final class DevelopmentStrategy
1919
{
20-
/** @var Bar */
21-
private $bar;
22-
23-
/** @var BlueScreen */
24-
private $blueScreen;
25-
26-
/** @var DeferredContent */
27-
private $defer;
20+
private Bar $bar;
21+
private BlueScreen $blueScreen;
22+
private DeferredContent $defer;
2823

2924

3025
public function __construct(Bar $bar, BlueScreen $blueScreen, DeferredContent $defer)

0 commit comments

Comments
 (0)