Skip to content

Commit

Permalink
move error_get_last w/ fatal to separate test
Browse files Browse the repository at this point in the history
  • Loading branch information
ericnorris committed Jan 13, 2025
1 parent aaa2443 commit 4db32ac
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 52 deletions.
53 changes: 1 addition & 52 deletions ext/standard/tests/general_functions/error_get_last.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,7 @@ $a = $b;

var_dump(error_get_last());

function trigger_fatal_error_with_stacktrace() {
ini_set('fatal_error_backtraces', true);

eval("class Foo {}; class Foo {}");
}

register_shutdown_function(function() {
var_dump(error_get_last());
echo "Done\n";
});

trigger_fatal_error_with_stacktrace();
echo "Done\n"
?>
--EXPECTF--
NULL
Expand All @@ -44,44 +33,4 @@ array(4) {
["line"]=>
int(11)
}

Fatal error: Cannot redeclare class Foo (%s) in %s on line %d
Stack trace:
#0 %serror_get_last.php(%d): eval()
#1 %serror_get_last.php(%d): trigger_fatal_error_with_stacktrace()
#2 {main}
array(5) {
["type"]=>
int(64)
["message"]=>
string(%d) "Cannot redeclare class Foo %s"
["file"]=>
string(%d) "%serror_get_last.php(%d) : eval()'d code"
["line"]=>
int(%d)
["trace"]=>
array(2) {
[0]=>
array(3) {
["file"]=>
string(%d) "%serror_get_last.php"
["line"]=>
int(%d)
["function"]=>
string(%d) "eval"
}
[1]=>
array(4) {
["file"]=>
string(%d) "%serror_get_last.php"
["line"]=>
int(%d)
["function"]=>
string(%d) "trigger_fatal_error_with_stacktrace"
["args"]=>
array(0) {
}
}
}
}
Done
59 changes: 59 additions & 0 deletions ext/standard/tests/general_functions/error_get_last_002.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
--TEST--
error_get_last() w/ fatal error
--INI--
fatal_error_backtraces=On
--FILE--
<?php

function trigger_fatal_error_with_stacktrace() {
eval("class Foo {}; class Foo {}");
}

register_shutdown_function(function() {
var_dump(error_get_last());
echo "Done\n";
});

trigger_fatal_error_with_stacktrace();
?>
--EXPECTF--
Fatal error: Cannot redeclare class Foo (%s) in %s on line %d
Stack trace:
#0 %serror_get_last_002.php(%d): eval()
#1 %serror_get_last_002.php(%d): trigger_fatal_error_with_stacktrace()
#2 {main}
array(5) {
["type"]=>
int(64)
["message"]=>
string(%d) "Cannot redeclare class Foo %s"
["file"]=>
string(%d) "%serror_get_last_002.php(%d) : eval()'d code"
["line"]=>
int(%d)
["trace"]=>
array(2) {
[0]=>
array(3) {
["file"]=>
string(%d) "%serror_get_last_002.php"
["line"]=>
int(%d)
["function"]=>
string(%d) "eval"
}
[1]=>
array(4) {
["file"]=>
string(%d) "%serror_get_last_002.php"
["line"]=>
int(%d)
["function"]=>
string(%d) "trigger_fatal_error_with_stacktrace"
["args"]=>
array(0) {
}
}
}
}
Done

0 comments on commit 4db32ac

Please sign in to comment.