Skip to content

Commit d4aad96

Browse files
committed
Update Tracy core
1 parent 99eb2f4 commit d4aad96

31 files changed

+301
-187
lines changed

TracyDebugger.module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.27.4',
30+
'version' => '4.27.5',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',

panels/RequestInfoPanel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ private function getImages($p) {
10401040

10411041

10421042
private function imageStr($inputfield, $image) {
1043+
if(!$image instanceof PageImage) return '';
10431044
$imagePreview = '';
10441045
if(isset($inputfield) && $inputfield) {
10451046
$thumb = $inputfield->getAdminThumb($image);

tracy-2.11.x/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"nette/di": "^3.0",
2525
"nette/http": "^3.0",
2626
"nette/mail": "^3.0 || ^4.0",
27-
"nette/tester": "^2.2",
27+
"nette/tester": "^2.6",
2828
"latte/latte": "^2.5 || ^3.0",
2929
"psr/log": "^1.0 || ^2.0 || ^3.0",
30-
"phpstan/phpstan-nette": "^2.0@stable"
30+
"phpstan/phpstan": "^2.0@stable"
3131
},
3232
"conflict": {
3333
"nette/di": "<3.0"

tracy-2.11.x/examples/dump.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@
3535
echo "<h2>Objects</h2>\n";
3636
echo "<p>Hover over the name <code>\$baz</code> to see property declaring class and over the hash <code>#5</code> to see same objects.</p>\n";
3737

38+
enum Suit
39+
{
40+
case Clubs;
41+
case Diamonds;
42+
case Hearts;
43+
case Spades;
44+
}
45+
3846
class ParentClass
3947
{
4048
public $foo = [10, 20];
4149

4250
protected $bar = 30;
4351

4452
private $baz = 'parent';
53+
54+
public Suit $enum = Suit::Clubs;
4555
}
4656

4757
#[\AllowDynamicProperties]
@@ -87,7 +97,8 @@ class ChildClass extends ParentClass
8797

8898
$arr = [
8999
fopen(__FILE__, 'r'),
90-
new class {},
100+
new class {
101+
},
91102
function ($x, $y) use (&$arr, $obj) {},
92103
];
93104

tracy-2.11.x/src/Bridges/Nette/Bridge.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ class Bridge
2424
public static function initialize(): void
2525
{
2626
$blueScreen = Tracy\Debugger::getBlueScreen();
27-
$blueScreen->addAction([self::class, 'renderMemberAccessException']);
28-
$blueScreen->addPanel([self::class, 'renderNeonError']);
27+
$blueScreen->addAction(self::renderMemberAccessException(...));
28+
$blueScreen->addPanel(self::renderNeonError(...));
2929
}
3030

3131

32+
/** @return array{link: string, label: string}|null */
3233
public static function renderMemberAccessException(?\Throwable $e): ?array
3334
{
3435
if (!$e instanceof Nette\MemberAccessException && !$e instanceof \LogicException) {
@@ -39,7 +40,7 @@ public static function renderMemberAccessException(?\Throwable $e): ?array
3940
do {
4041
$loc = array_shift($trace);
4142
} while (($loc['class'] ?? null) === Nette\Utils\ObjectHelpers::class);
42-
if (!isset($loc['file'])) {
43+
if (!isset($loc['file'], $loc['line'])) {
4344
return null;
4445
}
4546

@@ -61,6 +62,7 @@ public static function renderMemberAccessException(?\Throwable $e): ?array
6162
}
6263

6364

65+
/** @return array{tab: string, panel: string}|null */
6466
public static function renderNeonError(?\Throwable $e): ?array
6567
{
6668
if (!$e instanceof Nette\Neon\Exception || !preg_match('#line (\d+)#', $e->getMessage(), $m)) {
@@ -70,7 +72,7 @@ public static function renderNeonError(?\Throwable $e): ?array
7072
?? Helpers::findTrace($e->getTrace(), [Nette\DI\Config\Adapters\NeonAdapter::class, 'load'])
7173
) {
7274
$panel = '<p><b>File:</b> ' . Helpers::editorLink($trace['args'][0], (int) $m[1]) . '</p>'
73-
. self::highlightNeon(file_get_contents($trace['args'][0]), (int) $m[1]);
75+
. self::highlightNeon((string) file_get_contents($trace['args'][0]), (int) $m[1]);
7476

7577
} elseif ($trace = Helpers::findTrace($e->getTrace(), [Nette\Neon\Decoder::class, 'decode'])) {
7678
$panel = self::highlightNeon($trace['args'][0], (int) $m[1]);

tracy-2.11.x/src/Bridges/Nette/MailSender.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,13 @@
1818
*/
1919
class MailSender
2020
{
21-
private Nette\Mail\Mailer $mailer;
22-
23-
/** sender of email notifications */
24-
private ?string $fromEmail = null;
25-
26-
/** actual host on which notification occurred */
27-
private ?string $host = null;
28-
29-
30-
public function __construct(Nette\Mail\Mailer $mailer, ?string $fromEmail = null, ?string $host = null)
31-
{
32-
$this->mailer = $mailer;
33-
$this->fromEmail = $fromEmail;
34-
$this->host = $host;
21+
public function __construct(
22+
private readonly Nette\Mail\Mailer $mailer,
23+
/** sender of email notifications */
24+
private readonly ?string $fromEmail = null,
25+
/** actual host on which notification occurred */
26+
private readonly ?string $host = null,
27+
) {
3528
}
3629

3730

@@ -42,7 +35,7 @@ public function send(mixed $message, string $email): void
4235
$mail = new Nette\Mail\Message;
4336
$mail->setHeader('X-Mailer', 'Tracy');
4437
if ($this->fromEmail || Nette\Utils\Validators::isEmail("noreply@$host")) {
45-
$mail->setFrom($this->fromEmail ?: "noreply@$host");
38+
$mail->setFrom($this->fromEmail ?? "noreply@$host");
4639
}
4740

4841
foreach (explode(',', $email) as $item) {

tracy-2.11.x/src/Bridges/Nette/TracyExtension.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ class TracyExtension extends Nette\DI\CompilerExtension
2525

2626

2727
public function __construct(
28-
private bool $debugMode = false,
29-
private bool $cliMode = false,
28+
private readonly bool $debugMode = false,
29+
private readonly bool $cliMode = false,
3030
) {
3131
}
3232

@@ -79,6 +79,9 @@ public function loadConfiguration(): void
7979

8080
public function afterCompile(Nette\PhpGenerator\ClassType $class): void
8181
{
82+
$config = $this->config;
83+
\assert($config instanceof \stdClass);
84+
8285
$initialize = $this->initialization ?? new Nette\PhpGenerator\Closure;
8386
$initialize->addBody('if (!Tracy\Debugger::isEnabled()) { return; }');
8487

@@ -93,7 +96,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
9396
$initialize->addBody('Tracy\Debugger::setLogger($logger);');
9497
}
9598

96-
$options = (array) $this->config;
99+
$options = (array) $config;
97100
unset($options['bar'], $options['blueScreen'], $options['netteMailer']);
98101

99102
foreach (['logSeverity', 'strictMode', 'scream'] as $key) {
@@ -105,7 +108,11 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
105108
foreach ($options as $key => $value) {
106109
if ($value !== null) {
107110
$tbl = [
108-
'keysToHide' => 'array_push(Tracy\Debugger::getBlueScreen()->keysToHide, ... ?)',
111+
'keysToHide' => <<<'XX'
112+
$keysToHide = ?;
113+
array_push(Tracy\Debugger::$keysToHide, ...$keysToHide);
114+
array_push(Tracy\Debugger::getBlueScreen()->keysToHide, ...$keysToHide);
115+
XX,
109116
'fromEmail' => 'if ($logger instanceof Tracy\Logger) $logger->fromEmail = ?',
110117
'emailSnooze' => 'if ($logger instanceof Tracy\Logger) $logger->emailSnooze = ?',
111118
];
@@ -116,9 +123,9 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
116123
}
117124
}
118125

119-
if ($this->config->netteMailer && $builder->getByType(Nette\Mail\IMailer::class)) {
126+
if ($config->netteMailer && $builder->getByType(Nette\Mail\IMailer::class)) {
120127
$params = [];
121-
$params['fromEmail'] = $this->config->fromEmail;
128+
$params['fromEmail'] = $config->fromEmail;
122129
if (class_exists(Nette\Http\Request::class)) {
123130
$params['host'] = new Statement('$this->getByType(?, false)\?->getUrl()->getHost()', [Nette\Http\Request::class]);
124131
}
@@ -129,8 +136,8 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
129136
}
130137

131138
if ($this->debugMode) {
132-
foreach ($this->config->bar as $item) {
133-
if (is_string($item) && substr($item, 0, 1) === '@') {
139+
foreach ($config->bar as $item) {
140+
if (is_string($item) && str_starts_with($item, '@')) {
134141
$item = new Statement(['@' . $builder::THIS_CONTAINER, 'getService'], [substr($item, 1)]);
135142
} elseif (is_string($item)) {
136143
$item = new Statement($item);
@@ -152,7 +159,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
152159
}
153160
}
154161

155-
foreach ($this->config->blueScreen as $item) {
162+
foreach ($config->blueScreen as $item) {
156163
$initialize->addBody($builder->formatPhp(
157164
'$this->getService(?)->addPanel(?);',
158165
Nette\DI\Helpers::filterArguments([$this->prefix('blueScreen'), $item]),

tracy-2.11.x/src/Bridges/Psr/PsrToTracyLoggerAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ class PsrToTracyLoggerAdapter implements Tracy\ILogger
3131

3232

3333
public function __construct(
34-
private Psr\Log\LoggerInterface $psrLogger,
34+
private readonly Psr\Log\LoggerInterface $psrLogger,
3535
) {
3636
}
3737

3838

39-
public function log(mixed $value, string $level = self::INFO)
39+
public function log(mixed $value, string $level = self::INFO): void
4040
{
4141
if ($value instanceof \Throwable) {
4242
$message = get_debug_type($value) . ': ' . $value->getMessage() . ($value->getCode() ? ' #' . $value->getCode() : '') . ' in ' . $value->getFile() . ':' . $value->getLine();

tracy-2.11.x/src/Bridges/Psr/TracyToPsrLoggerAdapter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ class TracyToPsrLoggerAdapter extends Psr\Log\AbstractLogger
3232

3333

3434
public function __construct(
35-
private Tracy\ILogger $tracyLogger,
35+
private readonly Tracy\ILogger $tracyLogger,
3636
) {
3737
}
3838

3939

40+
/** @param string|\Stringable $message */
4041
public function log($level, $message, array $context = []): void
4142
{
4243
$level = self::LevelMap[$level] ?? Tracy\ILogger::ERROR;

tracy-2.11.x/src/Tracy/Bar/Bar.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ class Bar
2424

2525
/**
2626
* Add custom panel.
27-
* @return static
2827
*/
29-
public function addPanel(IBarPanel $panel, ?string $id = null): self
28+
public function addPanel(IBarPanel $panel, ?string $id = null): static
3029
{
3130
if ($id === null) {
3231
$c = 0;
@@ -105,13 +104,14 @@ public function render(DeferredContent $defer): void
105104
} else {
106105
$nonceAttr = Helpers::getNonceAttr();
107106
$async = false;
108-
Debugger::removeOutputBuffers(false);
107+
Debugger::removeOutputBuffers(errorOccurred: false);
109108
require __DIR__ . '/assets/loader.phtml';
110109
}
111110
}
112111
}
113112

114113

114+
/** @return array{bar: string, panels: string} */
115115
private function renderPartial(string $type, string $suffix = ''): array
116116
{
117117
$panels = $this->renderPanels($suffix);
@@ -127,12 +127,15 @@ private function renderPartial(string $type, string $suffix = ''): array
127127
}
128128

129129

130+
/** @return \stdClass[] */
130131
private function renderPanels(string $suffix = ''): array
131132
{
132-
set_error_handler(function (int $severity, string $message, string $file, int $line) {
133+
set_error_handler(function (int $severity, string $message, string $file, int $line): bool {
133134
if (error_reporting() & $severity) {
134135
throw new \ErrorException($message, 0, $severity, $file, $line);
135136
}
137+
138+
return true;
136139
});
137140

138141
$obLevel = ob_get_level();

0 commit comments

Comments
 (0)