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

tests/Tracy/Debugger.strict.console.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function second($arg1, $arg2)
3636

3737
function third($arg1)
3838
{
39-
$x++;
39+
$x = &pi();
4040
}
4141

4242

tests/Tracy/Debugger.strict.html.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function second($arg1, $arg2)
4040

4141
function third($arg1)
4242
{
43-
$x++;
43+
$x = &pi();
4444
}
4545

4646

tests/Tracy/Debugger.warnings.console.phpt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,17 @@ function second($arg1, $arg2)
3434

3535
function third($arg1)
3636
{
37-
mktime(); // E_DEPRECATED
38-
$x++; // E_NOTICE
39-
min(1); // E_WARNING
37+
$x = &pi(); // E_NOTICE
38+
hex2bin('a'); // E_WARNING
4039
require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
4140
}
4241

4342

4443
first(10, 'any string');
4544
Assert::match("
46-
Deprecated: mktime(): You should be using the time() function instead in %a% on line %d%
45+
Notice: Only variables should be assigned by reference in %a% on line %d%
4746
48-
Notice: Undefined variable: x in %a% on line %d%
49-
50-
Warning: %a% in %a% on line %d%
47+
Warning: hex2bin(): Hexadecimal input string must have an even length in %a% on line %d%
5148
5249
Warning: Unsupported declare 'foo' in %a% on line %d%
5350
", ob_get_clean());

tests/Tracy/Debugger.warnings.html.phpt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,11 @@ Warning: Unsupported declare \'foo\' in %a% on line %d%%A%', $output);
3636
Assert::match('%A%<table class="tracy-sortable">
3737
<tr>
3838
<td class="tracy-right">1%a%</td>
39-
<td><pre>PHP Deprecated: mktime(): You should be using the time() function instead in %a%:%d%</a></pre></td>
39+
<td><pre>PHP Notice: Only variables should be assigned by reference in %a%:%d%</a></pre></td>
4040
</tr>
4141
<tr>
4242
<td class="tracy-right">1%a%</td>
43-
<td><pre>PHP Notice: Undefined variable: x in %a%:%d%</a></pre></td>
44-
</tr>
45-
<tr>
46-
<td class="tracy-right">1%a%</td>
47-
<td><pre>PHP Warning: %a% in %a%:%d%</a></pre></td>
43+
<td><pre>PHP Warning: hex2bin(): Hexadecimal input string must have an even length in %a%:%d%</a></pre></td>
4844
</tr>
4945
</table>
5046
</div>%A%', $panelContent);
@@ -66,9 +62,8 @@ function second($arg1, $arg2)
6662

6763
function third($arg1)
6864
{
69-
mktime(); // E_DEPRECATED
70-
$x++; // E_NOTICE
71-
min(1); // E_WARNING
65+
$x = &pi(); // E_NOTICE
66+
hex2bin('a'); // E_WARNING
7267
require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
7368
}
7469

tests/Tracy/Debugger.warnings.production.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Debugger::$productionMode = true;
1717

1818
Debugger::enable();
1919

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

tests/Tracy/Helpers.improveException.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ test(function () use ($obj) { // suggest only static property
173173
} catch (\Error $e) {
174174
}
175175
Helpers::improveException($e);
176-
Assert::same('Access to undeclared static property: TestClass::$publicStaticX, did you mean $publicStatic?', $e->getMessage());
176+
Assert::match('Access to undeclared static property%a?% TestClass::$publicStaticX, did you mean $publicStatic?', $e->getMessage());
177177
Assert::match('editor://fix/?file=%a%Helpers.improveException.phpt&line=%d%&search=%3A%3A%24publicStaticX&replace=%3A%3A%24publicStatic', $e->tracyAction['link']);
178178
Assert::same('fix it', $e->tracyAction['label']);
179179
});
@@ -184,7 +184,7 @@ test(function () use ($obj) { // suggest only public static property
184184
} catch (\Error $e) {
185185
}
186186
Helpers::improveException($e);
187-
Assert::same('Access to undeclared static property: TestClass::$protectedMethodX', $e->getMessage());
187+
Assert::match('Access to undeclared static property%a?% TestClass::$protectedMethodX', $e->getMessage());
188188
Assert::false(isset($e->tracyAction));
189189
});
190190

tests/Tracy/PHP.errorHandler.phpt

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/Tracy/expected/Debugger.error-in-eval.expect

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<tr><th>$message</th><td><pre class="tracy-dump"><span class="tracy-dump-string">"The my error"</span> (%d%)
6060
</pre>
6161
</td></tr>
62-
<tr><th>$error_type</th><td><pre class="tracy-dump"><span class="tracy-dump-number">256</span>
62+
<tr><th>$error_%a%</th><td><pre class="tracy-dump"><span class="tracy-dump-number">256</span>
6363
</pre>
6464
</td></tr>
6565
</table>
@@ -99,23 +99,7 @@
9999
</li>
100100
</ol>
101101
</div></div>
102-
103-
104-
<div class="panel">
105-
<h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Variables</a></h2>
106-
107-
<div class="tracy-collapsed inner">
108-
<div class="outer">
109-
<table class="tracy-sortable">
110-
<tr><th>$user</th><td><pre class="tracy-dump"><span class="tracy-dump-string">"root"</span> (4)
111-
</pre>
112-
</td></tr>
113-
<tr><th>$pass</th><td><pre class="tracy-dump"><span class="tracy-dump-string">"*****"</span> (5)
114-
</pre>
115-
</td></tr>
116-
</table>
117-
</div>
118-
</div></div>
102+
%A%
119103

120104

121105

tests/Tracy/expected/Debugger.exception.html.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Last muted error</a></h2>
118118
<div class="tracy-collapsed inner">
119119

120-
<h3>Notice: Undefined variable: undefined</h3>
120+
<h3>Warning: hex2bin(): Hexadecimal input string must have an even length</h3>
121121
<p><a href="editor:%a%" title="%a%Debugger.exception.html.phpt:%d%">%a%<b>Debugger.exception.html.phpt</b>:%d%</a></p>
122122
<div>%A%</div>
123123

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11

2-
Deprecated: mktime(): You should be using the time() function instead in %a% on line %d%
2+
Notice: Only variables should be assigned by reference in %a% on line %d%
33

4-
Notice: Undefined variable: x in %a% on line %d%
5-
6-
Warning: %a% in %a% on line %d%
4+
Warning: hex2bin(): Hexadecimal input string must have an even length in %a% on line %d%

tests/Tracy/expected/Debugger.strict.console.expect

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
ErrorException: Undefined variable: x in %a%
1+
ErrorException: Only variables should be assigned by reference in %a%
22
Stack trace:
3-
#0 %a%: Tracy\Debugger::errorHandler(8, '%a%', '%a%', %a%, Array)
3+
#0 %a%: Tracy\Debugger::errorHandler(8, '%a%', '%a%', %a%)
44
#1 %a%: third(Array)
55
#2 %a%: second(true, false)
66
#3 %a%: first(10, 'any string')

tests/Tracy/expected/Debugger.strict.html.expect

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta name="robots" content="noindex">
66
<meta name="generator" content="Tracy by Nette Framework">
77

8-
<title>Notice: Undefined variable: x</title>
8+
<title>Notice: Only variables should be assigned by reference</title>
99
<!-- in %a%:%d% -->
1010

1111
%A%
@@ -19,7 +19,7 @@
1919
<div id="tracy-bs-error" class="panel">
2020
<p>Notice</p>
2121

22-
<h1><span>Undefined variable: x</span>
22+
<h1><span>Only variables should be assigned by reference</span>
2323
<a href="%a%" target="_blank" rel="noreferrer noopener">search&#x25ba;</a>
2424
</h1>
2525
</div>
@@ -106,20 +106,7 @@
106106
</li>
107107
</ol>
108108
</div></div>
109-
110-
111-
<div class="panel">
112-
<h2><a data-tracy-ref="^+" class="tracy-toggle tracy-collapsed">Variables</a></h2>
113-
114-
<div class="tracy-collapsed inner">
115-
<div class="outer">
116-
<table class="tracy-sortable">
117-
<tr><th>$arg1</th><td><pre class="tracy-dump" data-tracy-dump='[[0,1],[1,2],[2,3]]'></pre>
118-
</td></tr>%A?%
119-
</table>
120-
</div>
121-
</div></div>
122-
109+
%A%
123110

124111

125112
<div class="panel">

0 commit comments

Comments
 (0)