xref: /PHP-7.4/ext/simplexml/tests/bug37565.phpt (revision 3121b717)
1--TEST--
2Bug #37565 (Using reflection::export with simplexml causing a crash)
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7
8function my_error_handler($errno, $errstr, $errfile, $errline) {
9	    echo "Error: $errstr\n";
10}
11
12set_error_handler('my_error_handler');
13
14class Setting extends ReflectionObject
15{
16}
17
18try {
19	Reflection::export(simplexml_load_string('<test/>', 'Setting'));
20} catch (Error $e) {
21	my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
22}
23
24try {
25	Reflection::export(simplexml_load_file('data:,<test/>', 'Setting'));
26} catch (Error $e) {
27	my_error_handler($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
28}
29
30?>
31===DONE===
32--EXPECT--
33Error: simplexml_load_string() expects parameter 2 to be a class name derived from SimpleXMLElement, 'Setting' given
34Error: Function Reflection::export() is deprecated
35Error: Argument 1 passed to Reflection::export() must implement interface Reflector, null given
36Error: simplexml_load_file() expects parameter 2 to be a class name derived from SimpleXMLElement, 'Setting' given
37Error: Function Reflection::export() is deprecated
38Error: Argument 1 passed to Reflection::export() must implement interface Reflector, null given
39===DONE===
40