@@ -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 ]),
0 commit comments