Skip to content

Commit 458bb14

Browse files
committed
compatibility with PHP 8.0
1 parent d3bb9f4 commit 458bb14

22 files changed

+42
-103
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ php:
44
- 7.2
55
- 7.3
66
- 7.4
7+
- 8.0snapshot
78

89
env:
910
- PHP_BIN=php

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ composer require tracy/tracy
4141
Alternatively, you can download the whole package or [tracy.phar](https://github.com/nette/tester/releases) file.
4242

4343
| Tracy | PHP | compatible with browsers
44-
|-----------|---------------|----------
45-
| Tracy 2.6 | PHP 7.1 – 7.4 | Chrome 49+, Firefox 45+, MS Edge 14+, Safari 10+ and iOS Safari 10.2+
44+
|-----------|-----------------|----------
45+
| Tracy 2.6 | PHP 7.1 – 8.0 | Chrome 49+, Firefox 45+, MS Edge 14+, Safari 10+ and iOS Safari 10.2+
4646
| Tracy 2.5 | PHP 5.4.4 – 7.3 | Chrome 49+, Firefox 45+, MS Edge 12+, Safari 10+ and iOS Safari 10.2+
4747
| Tracy 2.4 | PHP 5.4.4 – 7.2 | Chrome 29+, Firefox 28+, IE 11+ (except AJAX), MS Edge 12+, Safari 9+ and iOS Safari 9.2+
4848

src/Tracy/Helpers.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public static function getSource(): string
166166
. $_SERVER['REQUEST_URI'];
167167
} else {
168168
return 'CLI (PID: ' . getmypid() . ')'
169-
. ': ' . implode(' ', array_map([self::class, 'escapeArg'], $_SERVER['argv']));
169+
. (isset($_SERVER['argv']) ? ': ' . implode(' ', array_map([self::class, 'escapeArg'], $_SERVER['argv'])) : '');
170170
}
171171
}
172172

@@ -188,7 +188,7 @@ public static function improveException(\Throwable $e): void
188188
$message .= ", did you mean $hint()?";
189189
$replace = ["$m[2](", "$hint("];
190190

191-
} elseif (preg_match('#^Undefined variable: (\w+)#', $message, $m) && !empty($e->context)) {
191+
} elseif (preg_match('#^Undefined variable:? \$?(\w+)#', $message, $m) && !empty($e->context)) {
192192
$hint = self::getSuggestion(array_keys($e->context), $m[1]);
193193
$message = "Undefined variable $$m[1], did you mean $$hint?";
194194
$replace = ["$$m[1]", "$$hint"];
@@ -200,7 +200,7 @@ public static function improveException(\Throwable $e): void
200200
$message .= ", did you mean $$hint?";
201201
$replace = ["->$m[2]", "->$hint"];
202202

203-
} elseif (preg_match('#^Access to undeclared static property: ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
203+
} elseif (preg_match('#^Access to undeclared static property:? ([\w\\\\]+)::\$(\w+)#', $message, $m)) {
204204
$rc = new \ReflectionClass($m[1]);
205205
$items = array_intersect($rc->getProperties(\ReflectionProperty::IS_PUBLIC), $rc->getProperties(\ReflectionProperty::IS_STATIC));
206206
$hint = self::getSuggestion($items, $m[2]);
@@ -223,7 +223,7 @@ public static function improveException(\Throwable $e): void
223223
/** @internal */
224224
public static function improveError(string $message, array $context = []): string
225225
{
226-
if (preg_match('#^Undefined variable: (\w+)#', $message, $m) && $context) {
226+
if (preg_match('#^Undefined variable:? \$?(\w+)#', $message, $m) && $context) {
227227
$hint = self::getSuggestion(array_keys($context), $m[1]);
228228
return $hint ? "Undefined variable $$m[1], did you mean $$hint?" : $message;
229229

tests/Tracy/Debugger.autoloading.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* Test: Tracy\Debugger autoloading.
55
* @outputMatch %A%: Declaration of B::test(%a?%) should be compatible %a% A::test() in %A%
6+
* @phpVersion < 8
67
*/
78

89
declare(strict_types=1);

tests/Tracy/Debugger.exception.html.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ function third($arg1)
4444

4545

4646
define('MY_CONST', 123);
47-
echo @$undefined;
47+
@hex2bin('a'); // E_WARNING
4848
first(10, 'any string');

tests/Tracy/Debugger.logSeverity.E_NOTICE.development.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require __DIR__ . '/../bootstrap.php';
1717
Debugger::enable(Debugger::DEVELOPMENT, getTempDir());
1818
Debugger::$logSeverity = E_NOTICE;
1919

20-
$variable = $missingVariable;
20+
$variable = &pi();
2121

2222
Assert::count(0, glob(getTempDir() . '/exception*.html'));
2323
Assert::count(0, glob(getTempDir() . '/error.log'));

tests/Tracy/Debugger.logSeverity.E_NOTICE.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ require __DIR__ . '/../bootstrap.php';
1717
Debugger::enable(Debugger::PRODUCTION, getTempDir());
1818
Debugger::$logSeverity = E_NOTICE;
1919

20-
$variable = $missingVariable;
20+
$variable = &pi();
2121

22-
Assert::same('Undefined variable: missingVariable', error_get_last()['message']);
22+
Assert::same('Only variables should be assigned by reference', error_get_last()['message']);
2323

2424
Assert::count(1, glob(getTempDir() . '/exception*.html'));
2525
Assert::count(1, glob(getTempDir() . '/error.log'));

tests/Tracy/Debugger.logging.warnings.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Debugger::enable(Debugger::PRODUCTION, $logDirectory, 'admin@example.com');
2424

2525

2626
// throw error
27-
$a++;
27+
hex2bin('a'); // E_WARNING
2828

29-
Assert::match('%a%PHP Notice: Undefined variable: a in %a%', file_get_contents($logDirectory . '/error.log'));
29+
Assert::match('%a%PHP Warning: hex2bin(): Hexadecimal input string must have an even length in %a%', file_get_contents($logDirectory . '/error.log'));
3030
Assert::true(is_file($logDirectory . '/email-sent'));

tests/Tracy/Debugger.scream.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ header('Content-Type: text/plain; charset=utf-8');
1919

2020
Debugger::enable();
2121

22-
@mktime(); // E_DEPRECATED
23-
@$x++; // E_NOTICE
24-
@min(1); // E_WARNING
22+
@$x = &pi(); // E_NOTICE
23+
@hex2bin('a'); // E_WARNING
2524
@require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING (not working)

tests/Tracy/Debugger.shut-up.warnings.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ header('Content-Type: text/plain; charset=utf-8');
1818

1919
Debugger::enable();
2020

21-
@mktime(); // E_DEPRECATED
22-
@$x++; // E_NOTICE
23-
@min(1); // E_WARNING
21+
@$x = &pi(); // E_NOTICE
22+
@hex2bin('a'); // E_WARNING
2423
@require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING

0 commit comments

Comments
 (0)