Skip to content

[ErrorHandler] Fix test fatal_with_nested_handlers for PHP 8.1 #42761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
--TEST--
Test catching fatal errors when handlers are nested
--SKIPIF--
<?php if (\PHP_VERSION_ID < 80100) echo 'skip' ?>
--FILE--
<?php

Expand Down Expand Up @@ -36,6 +38,9 @@ array(1) {
string(37) "Error and exception handlers do match"
}
object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
["message":protected]=>
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
%a
["error":"Symfony\Component\ErrorHandler\Error\FatalError":private]=>
array(4) {
["type"]=>
Expand All @@ -47,7 +52,4 @@ object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
["line"]=>
int(%d)
}
["message":protected]=>
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
%a
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--TEST--
Test catching fatal errors when handlers are nested
--SKIPIF--
<?php if (\PHP_VERSION_ID >= 80100) echo 'skip' ?>
--FILE--
<?php

namespace Symfony\Component\ErrorHandler;

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = \dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

Debug::enable();
ini_set('display_errors', 0);

$eHandler = set_error_handler('var_dump');
$xHandler = set_exception_handler('var_dump');

var_dump([
$eHandler[0] === $xHandler[0] ? 'Error and exception handlers do match' : 'Error and exception handlers are different',
]);

$eHandler[0]->setExceptionHandler('print_r');

if (true) {
class Broken implements \JsonSerializable
{
}
}

?>
--EXPECTF--
array(1) {
[0]=>
string(37) "Error and exception handlers do match"
}
object(Symfony\Component\ErrorHandler\Error\FatalError)#%d (%d) {
["error":"Symfony\Component\ErrorHandler\Error\FatalError":private]=>
array(4) {
["type"]=>
int(1)
["message"]=>
string(179) "Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
["file"]=>
string(%d) "%s"
["line"]=>
int(%d)
}
["message":protected]=>
string(186) "Error: Class Symfony\Component\ErrorHandler\Broken contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (JsonSerializable::jsonSerialize)"
%a
}