xref: /PHP-7.2/ext/simplexml/tests/bug37565.phpt (revision 64b167d2)
1--TEST--
2Bug #37565 (Using reflection::export with simplexml causing a crash)
3--SKIPIF--
4<?php if (!extension_loaded("simplexml") || !extension_loaded('reflection')) 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--EXPECTF--
33Error: simplexml_load_string() expects parameter 2 to be a class name derived from SimpleXMLElement, 'Setting' given
34Error: Argument 1 passed to Reflection::export() must implement interface Reflector, null given
35Error: simplexml_load_file() expects parameter 2 to be a class name derived from SimpleXMLElement, 'Setting' given
36Error: Argument 1 passed to Reflection::export() must implement interface Reflector, null given
37===DONE===
38