Skip to content

Commit 3da92fa

Browse files
committed
improved coding style
1 parent e43a849 commit 3da92fa

40 files changed

+227
-223
lines changed

src/Bridges/Nette/TracyExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
8383
'$this->getService(?)->addPanel(?);',
8484
Nette\DI\Compiler::filterArguments([
8585
$this->prefix('bar'),
86-
is_string($item) ? new Nette\DI\Statement($item) : $item]
87-
)
86+
is_string($item) ? new Nette\DI\Statement($item) : $item,
87+
])
8888
));
8989
}
9090
}

src/Tracy/BlueScreen.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static function highlightPhp($source, $line, $lines = 15, array $vars = N
115115
$out .= static::highlightLine($source, $line, $lines);
116116

117117
if ($vars) {
118-
$out = preg_replace_callback('#">\$(\w+)(&nbsp;)?</span>#', function($m) use ($vars) {
118+
$out = preg_replace_callback('#">\$(\w+)(&nbsp;)?</span>#', function ($m) use ($vars) {
119119
return array_key_exists($m[1], $vars)
120120
? '" title="'
121121
. str_replace('"', '&quot;', trim(strip_tags(Dumper::toHtml($vars[$m[1]], [Dumper::DEPTH => 1]))))
@@ -139,7 +139,7 @@ public static function highlightLine($html, $line, $lines = 15)
139139
$source = explode("\n", "\n" . str_replace("\r\n", "\n", $html));
140140
$out = '';
141141
$spans = 1;
142-
$start = $i = max(1, $line - floor($lines * 2/3));
142+
$start = $i = max(1, $line - floor($lines * 2 / 3));
143143
while (--$i >= 1) { // find last highlighted block
144144
if (preg_match('#.*(</?span[^>]*>)#', $source[$i], $m)) {
145145
if ($m[1] !== '</span>') {

src/Tracy/Debugger.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ public static function exceptionHandler($exception, $exit = TRUE)
266266
} catch (\Exception $e) {
267267
try {
268268
self::log($e, self::EXCEPTION);
269-
} catch (\Exception $e) {}
269+
} catch (\Exception $e) {
270+
}
270271
}
271272

272273
if ($exit) {
@@ -307,7 +308,8 @@ public static function errorHandler($severity, $message, $file, $line, $context)
307308
$e->context = $context;
308309
try {
309310
self::log($e, self::ERROR);
310-
} catch (\Exception $foo) {}
311+
} catch (\Exception $foo) {
312+
}
311313
return NULL;
312314

313315
} elseif (!self::$productionMode && !isset($_GET['_tracy_skip_error'])
@@ -328,7 +330,8 @@ public static function errorHandler($severity, $message, $file, $line, $context)
328330
} elseif (self::$productionMode) {
329331
try {
330332
self::log("$message in $file:$line", self::ERROR);
331-
} catch (\Exception $foo) {}
333+
} catch (\Exception $foo) {
334+
}
332335
return NULL;
333336

334337
} else {

src/Tracy/Dumper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static function toText($var, array $options = NULL)
127127
*/
128128
public static function toTerminal($var, array $options = NULL)
129129
{
130-
return htmlspecialchars_decode(strip_tags(preg_replace_callback('#<span class="tracy-dump-(\w+)">|</span>#', function($m) {
130+
return htmlspecialchars_decode(strip_tags(preg_replace_callback('#<span class="tracy-dump-(\w+)">|</span>#', function ($m) {
131131
return "\033[" . (isset($m[1], self::$terminalColors[$m[1]]) ? self::$terminalColors[$m[1]] : '0') . 'm';
132132
}, self::toHtml($var, $options))), ENT_QUOTES);
133133
}
@@ -280,7 +280,7 @@ private static function dumpResource(& $var, $options, $level)
280280
$out = "<span class=\"tracy-toggle tracy-collapsed\">$out</span>\n<div class=\"tracy-collapsed\">";
281281
foreach (call_user_func(self::$resources[$type], $var) as $k => $v) {
282282
$out .= '<span class="tracy-dump-indent"> ' . str_repeat('| ', $level) . '</span>'
283-
. '<span class="tracy-dump-key">' . htmlSpecialChars($k, ENT_IGNORE, 'UTF-8') . "</span> => " . self::dumpVar($v, $options, $level + 1);
283+
. '<span class="tracy-dump-key">' . htmlSpecialChars($k, ENT_IGNORE, 'UTF-8') . '</span> => ' . self::dumpVar($v, $options, $level + 1);
284284
}
285285
return $out . '</div>';
286286
}
@@ -397,7 +397,7 @@ public static function encodeString($s, $maxLength = NULL)
397397
foreach (array_merge(range("\x00", "\x1F"), range("\x7F", "\xFF")) as $ch) {
398398
$table[$ch] = '\x' . str_pad(dechex(ord($ch)), 2, '0', STR_PAD_LEFT);
399399
}
400-
$table["\\"] = '\\\\';
400+
$table['\\'] = '\\\\';
401401
$table["\r"] = '\r';
402402
$table["\n"] = '\n';
403403
$table["\t"] = '\t';
@@ -511,7 +511,8 @@ private static function findLocation()
511511
$location = $item;
512512
continue;
513513
}
514-
} catch (\ReflectionException $e) {}
514+
} catch (\ReflectionException $e) {
515+
}
515516
}
516517
break;
517518
}
@@ -522,7 +523,7 @@ private static function findLocation()
522523
return [
523524
$location['file'],
524525
$location['line'],
525-
trim(preg_match('#\w*dump(er::\w+)?\(.*\)#i', $line, $m) ? $m[0] : $line)
526+
trim(preg_match('#\w*dump(er::\w+)?\(.*\)#i', $line, $m) ? $m[0] : $line),
526527
];
527528
}
528529
}

src/Tracy/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static function editorUri($file, $line = NULL)
6060
public static function formatHtml($mask)
6161
{
6262
$args = func_get_args();
63-
return preg_replace_callback('#%#', function() use (& $args, & $count) {
63+
return preg_replace_callback('#%#', function () use (& $args, & $count) {
6464
return htmlspecialchars($args[++$count], ENT_IGNORE | ENT_QUOTES, 'UTF-8');
6565
}, $mask);
6666
}

src/Tracy/Logger.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function formatLogLine($message, $exceptionFile = NULL)
113113
@date('[Y-m-d H-i-s]'),
114114
preg_replace('#\s*\r?\n\s*#', ' ', $this->formatMessage($message)),
115115
' @ ' . Helpers::getSource(),
116-
$exceptionFile ? ' @@ ' . basename($exceptionFile) : NULL
116+
$exceptionFile ? ' @@ ' . basename($exceptionFile) : NULL,
117117
]);
118118
}
119119

@@ -145,7 +145,7 @@ protected function logException($exception, $file = NULL)
145145
$file = $file ?: $this->getExceptionFile($exception);
146146
if ($handle = @fopen($file, 'x')) {
147147
ob_start(); // double buffer prevents sending HTTP headers in some PHP
148-
ob_start(function($buffer) use ($handle) { fwrite($handle, $buffer); }, 4096);
148+
ob_start(function ($buffer) use ($handle) { fwrite($handle, $buffer); }, 4096);
149149
$bs = $this->blueScreen ?: new BlueScreen;
150150
$bs->render($exception);
151151
ob_end_flush();
@@ -190,7 +190,7 @@ public function defaultMailer($message, $email)
190190
["\n", PHP_EOL],
191191
[
192192
'headers' => implode("\n", [
193-
"From: " . ($this->fromEmail ?: "noreply@$host"),
193+
'From: ' . ($this->fromEmail ?: "noreply@$host"),
194194
'X-Mailer: Tracy',
195195
'Content-Type: text/plain; charset=UTF-8',
196196
'Content-Transfer-Encoding: 8bit',

tests/Tracy/Debugger.E_COMPILE_ERROR.console.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Debugger::enable();
2121

2222
$onFatalErrorCalled = FALSE;
2323

24-
register_shutdown_function(function() use (& $onFatalErrorCalled) {
24+
register_shutdown_function(function () use (& $onFatalErrorCalled) {
2525
Assert::true($onFatalErrorCalled);
2626
Assert::match(extension_loaded('xdebug') ? "
2727
Fatal error: Cannot re-assign \$this in %a%
@@ -44,7 +44,7 @@ Unable to log error: Directory is not specified.
4444
});
4545

4646

47-
Debugger::$onFatalError[] = function() use (& $onFatalErrorCalled) {
47+
Debugger::$onFatalError[] = function () use (& $onFatalErrorCalled) {
4848
$onFatalErrorCalled = TRUE;
4949
};
5050
ob_start();

tests/Tracy/Debugger.E_ERROR.console.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Debugger::enable();
2121

2222
$onFatalErrorCalled = FALSE;
2323

24-
register_shutdown_function(function() use (& $onFatalErrorCalled) {
24+
register_shutdown_function(function () use (& $onFatalErrorCalled) {
2525
Assert::true($onFatalErrorCalled);
2626
Assert::match(extension_loaded('xdebug') ? "
2727
Fatal error: Call to undefined function missing_function() in %a%
@@ -44,7 +44,7 @@ Unable to log error: Directory is not specified.
4444
});
4545

4646

47-
Debugger::$onFatalError[] = function() use (& $onFatalErrorCalled) {
47+
Debugger::$onFatalError[] = function () use (& $onFatalErrorCalled) {
4848
$onFatalErrorCalled = TRUE;
4949
};
5050
ob_start();

tests/Tracy/Debugger.E_ERROR.html.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Debugger::enable();
2626

2727
$onFatalErrorCalled = FALSE;
2828

29-
register_shutdown_function(function() use (& $onFatalErrorCalled) {
29+
register_shutdown_function(function () use (& $onFatalErrorCalled) {
3030
Assert::true($onFatalErrorCalled);
3131
$output = ob_get_clean();
3232
Assert::same(1, substr_count($output, '<!-- Tracy Debug Bar'));
@@ -35,7 +35,7 @@ register_shutdown_function(function() use (& $onFatalErrorCalled) {
3535
});
3636

3737

38-
Debugger::$onFatalError[] = function() use (& $onFatalErrorCalled) {
38+
Debugger::$onFatalError[] = function () use (& $onFatalErrorCalled) {
3939
$onFatalErrorCalled = TRUE;
4040
};
4141
ob_start();

tests/Tracy/Debugger.E_RECOVERABLE_ERROR.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ class TestClass
4040

4141
$obj = new TestClass;
4242

43-
Assert::exception(function() use ($obj) {
43+
Assert::exception(function () use ($obj) {
4444
// Invalid argument #1
4545
$obj->test1('hello');
4646
}, 'ErrorException', 'Argument 1 passed to TestClass::test1() must be %a% array, string given, called in %a%');
4747

48-
Assert::exception(function() use ($obj) {
48+
Assert::exception(function () use ($obj) {
4949
// Invalid argument #2
5050
$obj->test2('hello');
5151
}, 'ErrorException', 'Argument 1 passed to TestClass::test2() must be an instance of TestClass, string given, called in %a%');
5252

53-
Assert::exception(function() use ($obj) {
53+
Assert::exception(function () use ($obj) {
5454
// Invalid toString
5555
echo $obj;
5656
}, 'ErrorException', 'Method TestClass::__toString() must return a string value');

0 commit comments

Comments
 (0)