mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00

To get proper errors and sensible behaviour, as the current behaviour is somewhat insane and part of it should be axed ASAP. The behaviour is mostly intact with some minor BC breaks which are mentioned in UPGRADING. Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
--TEST--
|
|
Test xml_set_element_handler handlers as trampoline callback
|
|
--EXTENSIONS--
|
|
xml
|
|
--FILE--
|
|
<?php
|
|
|
|
class TrampolineTest {
|
|
public function __call(string $name, array $arguments) {
|
|
echo 'Trampoline for ', $name, PHP_EOL;
|
|
echo 'Tag: ', $arguments[1], PHP_EOL;
|
|
}
|
|
}
|
|
|
|
$o = new TrampolineTest();
|
|
$startCallback = [$o, 'start_handler'];
|
|
$endCallback = [$o, 'end_handler'];
|
|
|
|
$xml = <<<HERE
|
|
<a>
|
|
<b/>
|
|
<c>Text</c>
|
|
</a>
|
|
HERE;
|
|
|
|
$parser = xml_parser_create();
|
|
echo "2nd arg is rubbish:\n";
|
|
try {
|
|
xml_set_element_handler($parser, [], $endCallback);
|
|
} catch (\Throwable $e) {
|
|
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
|
}
|
|
echo "3rd arg is rubbish:\n";
|
|
try {
|
|
xml_set_element_handler($parser, $startCallback, []);
|
|
} catch (\Throwable $e) {
|
|
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
|
|
}
|
|
xml_parser_free($parser);
|
|
|
|
?>
|
|
--EXPECT--
|
|
2nd arg is rubbish:
|
|
TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null
|
|
3rd arg is rubbish:
|
|
TypeError: xml_set_element_handler(): Argument #2 ($start_handler) must be of type callable|string|null
|