Skip to content

Commit

Permalink
removed PHP 5 code
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 3, 2018
1 parent 8826ef4 commit 7622ce7
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 393 deletions.
2 changes: 1 addition & 1 deletion src/Tracy/Dumper.php
Expand Up @@ -175,7 +175,7 @@ private static function dumpDouble(&$var): string
{
$var = is_finite($var)
? ($tmp = json_encode($var)) . (strpos($tmp, '.') === false ? '.0' : '')
: str_replace('.0', '', var_export($var, true)); // workaround for PHP 7.0.2
: var_export($var, true);
return "<span class=\"tracy-dump-number\">$var</span>\n";
}

Expand Down
20 changes: 2 additions & 18 deletions tests/Tracy/Debugger.E_ERROR.console.phpt
Expand Up @@ -26,31 +26,15 @@ $onFatalErrorCalled = false;

register_shutdown_function(function () use (&$onFatalErrorCalled) {
Assert::true($onFatalErrorCalled);
Assert::match(PHP_MAJOR_VERSION > 5 ?
Assert::match(
"Error: Call to undefined function missing_function() in %a%
Stack trace:
#0 %a%: third(Array)
#1 %a%: second(true, false)
#2 %a%: first(10, 'any string')
#3 {main}
Unable to log error: Logging directory is not specified.
" : (extension_loaded('xdebug') ? '
Fatal error: Call to undefined function missing_function() in %a%
ErrorException: Call to undefined function missing_function() in %a%
Stack trace:
#0 %a%: third()
#1 %a%: second()
#2 %a%: first()
#3 {main}
Unable to log error: Logging directory is not specified.
' : '
Fatal error: Call to undefined function missing_function() in %a%
ErrorException: Call to undefined function missing_function() in %a%
Stack trace:
#0 [internal function]: Tracy\\Debugger::shutdownHandler()
#1 {main}
Unable to log error: Logging directory is not specified.
'), ob_get_clean());
", ob_get_clean());
echo 'OK!'; // prevents PHP bug #62725
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Tracy/Debugger.E_ERROR.html.phpt
Expand Up @@ -33,7 +33,7 @@ register_shutdown_function(function () use (&$onFatalErrorCalled) {
Assert::true($onFatalErrorCalled);
$output = ob_get_clean();
Assert::same(1, substr_count($output, '<!-- Tracy Debug Bar'));
Assert::matchFile(__DIR__ . '/expected/Debugger.E_ERROR.html' . (PHP_MAJOR_VERSION > 5 ? '' : (extension_loaded('xdebug') ? '.xdebug' : '.php5')) . '.expect', $output);
Assert::matchFile(__DIR__ . '/expected/Debugger.E_ERROR.html.expect', $output);
echo 'OK!'; // prevents PHP bug #62725
});

Expand Down
6 changes: 3 additions & 3 deletions tests/Tracy/Debugger.E_RECOVERABLE_ERROR.phpt
Expand Up @@ -42,14 +42,14 @@ $obj = new TestClass;
Assert::exception(function () use ($obj) {
// Invalid argument #1
$obj->test1('hello');
}, PHP_MAJOR_VERSION < 7 ? 'ErrorException' : 'TypeError', 'Argument 1 passed to TestClass::test1() must be %a% array, string given, called in %a%');
}, TypeError::class, 'Argument 1 passed to TestClass::test1() must be %a% array, string given, called in %a%');

Assert::exception(function () use ($obj) {
// Invalid argument #2
$obj->test2('hello');
}, PHP_MAJOR_VERSION < 7 ? 'ErrorException' : 'TypeError', 'Argument 1 passed to TestClass::test2() must be an instance of TestClass, string given, called in %a%');
}, TypeError::class, 'Argument 1 passed to TestClass::test2() must be an instance of TestClass, string given, called in %a%');

Assert::exception(function () use ($obj) {
// Invalid toString
echo $obj;
}, 'ErrorException', 'Method TestClass::__toString() must return a string value');
}, ErrorException::class, 'Method TestClass::__toString() must return a string value');
3 changes: 1 addition & 2 deletions tests/Tracy/Debugger.scream.phpt
Expand Up @@ -19,8 +19,7 @@ header('Content-Type: text/plain; charset=utf-8');

Debugger::enable();

@mktime(); // E_STRICT in PHP 5, E_DEPRECATED in PHP 7
PHP_MAJOR_VERSION < 7 ? @mktime(0, 0, 0, 1, 23, 1978, 1) : @mktime(); // E_DEPRECATED
@mktime(); // E_DEPRECATED
@$x++; // E_NOTICE
@min(1); // E_WARNING
@require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING (not working)
3 changes: 1 addition & 2 deletions tests/Tracy/Debugger.shut-up.warnings.phpt
Expand Up @@ -18,8 +18,7 @@ header('Content-Type: text/plain; charset=utf-8');

Debugger::enable();

@mktime(); // E_STRICT in PHP 5, E_DEPRECATED in PHP 7
PHP_MAJOR_VERSION < 7 ? @mktime(0, 0, 0, 1, 23, 1978, 1) : @mktime(); // E_DEPRECATED
@mktime(); // E_DEPRECATED
@$x++; // E_NOTICE
@min(1); // E_WARNING
@require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
7 changes: 2 additions & 5 deletions tests/Tracy/Debugger.warnings.console.phpt
Expand Up @@ -34,8 +34,7 @@ function second($arg1, $arg2)

function third($arg1)
{
mktime(); // E_STRICT in PHP 5, E_DEPRECATED in PHP 7
PHP_MAJOR_VERSION < 7 ? mktime(0, 0, 0, 1, 23, 1978, 1) : mktime(); // E_DEPRECATED
mktime(); // E_DEPRECATED
$x++; // E_NOTICE
min(1); // E_WARNING
require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
Expand All @@ -44,9 +43,7 @@ function third($arg1)

first(10, 'any string');
Assert::match("
%a%: mktime(): You should be using the time() function instead in %a% on line %d%
Deprecated: mktime(): %a%
Deprecated: mktime(): You should be using the time() function instead in %a% on line %d%
Notice: Undefined variable: x in %a% on line %d%
Expand Down
9 changes: 2 additions & 7 deletions tests/Tracy/Debugger.warnings.html.phpt
Expand Up @@ -36,11 +36,7 @@ Warning: Unsupported declare \'foo\' in %a% on line %d%%A%', $output);
Assert::match('%A%<table>
<tr>
<td class="tracy-right">1%a%</td>
<td><pre>PHP %a%: mktime(): You should be using the time() function instead in %a%:%d%</a></pre></td>
</tr>
<tr>
<td class="tracy-right">1%a%</td>
<td><pre>PHP Deprecated: mktime(): %a%</a></pre></td>
<td><pre>PHP Deprecated: mktime(): You should be using the time() function instead in %a%:%d%</a></pre></td>
</tr>
<tr>
<td class="tracy-right">1%a%</td>
Expand Down Expand Up @@ -70,8 +66,7 @@ function second($arg1, $arg2)

function third($arg1)
{
mktime(); // E_STRICT in PHP 5, E_DEPRECATED in PHP 7
PHP_MAJOR_VERSION < 7 ? mktime(0, 0, 0, 1, 23, 1978, 1) : mktime(); // E_DEPRECATED
mktime(); // E_DEPRECATED
$x++; // E_NOTICE
min(1); // E_WARNING
require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
Expand Down
3 changes: 1 addition & 2 deletions tests/Tracy/Debugger.warnings.production.phpt
Expand Up @@ -17,8 +17,7 @@ Debugger::$productionMode = true;

Debugger::enable();

mktime(); // E_STRICT in PHP 5, E_DEPRECATED in PHP 7
PHP_MAJOR_VERSION < 7 ? @mktime(0, 0, 0, 1, 23, 1978, 1) : @mktime(); // E_DEPRECATED
mktime(); // E_DEPRECATED
$x++; // E_NOTICE
min(1); // E_WARNING
require __DIR__ . '/fixtures/E_COMPILE_WARNING.php'; // E_COMPILE_WARNING
141 changes: 0 additions & 141 deletions tests/Tracy/expected/Debugger.E_ERROR.html.php5.expect

This file was deleted.

0 comments on commit 7622ce7

Please sign in to comment.