From d1ff6aac5c62919470506487399809fc382bcf16 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 23 Aug 2025 22:14:49 +0200 Subject: [PATCH 1/2] update xml_*_handler signature --- resources/functionMap.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/resources/functionMap.php b/resources/functionMap.php index 917169b68b..1dd0458494 100644 --- a/resources/functionMap.php +++ b/resources/functionMap.php @@ -11677,16 +11677,16 @@ 'xml_parser_free' => ['bool', 'parser'=>'resource'], 'xml_parser_get_option' => ['mixed', 'parser'=>'resource', 'option'=>'int'], 'xml_parser_set_option' => ['bool', 'parser'=>'resource', 'option'=>'int', 'value'=>'mixed'], -'xml_set_character_data_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], -'xml_set_default_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], -'xml_set_element_handler' => ['bool', 'parser'=>'resource', 'shdl'=>'callable', 'ehdl'=>'callable'], -'xml_set_end_namespace_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], -'xml_set_external_entity_ref_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], -'xml_set_notation_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], +'xml_set_character_data_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], +'xml_set_default_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], +'xml_set_element_handler' => ['bool', 'parser'=>'resource', 'shdl'=>'callable|string|null', 'ehdl'=>'callable|string|null'], +'xml_set_end_namespace_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], +'xml_set_external_entity_ref_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], +'xml_set_notation_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], 'xml_set_object' => ['bool', 'parser'=>'resource', 'obj'=>'object'], -'xml_set_processing_instruction_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], -'xml_set_start_namespace_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], -'xml_set_unparsed_entity_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable'], +'xml_set_processing_instruction_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], +'xml_set_start_namespace_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], +'xml_set_unparsed_entity_decl_handler' => ['bool', 'parser'=>'resource', 'hdl'=>'callable|string|null'], 'XMLDiff\Base::__construct' => ['void', 'nsname'=>'string'], 'XMLDiff\Base::diff' => ['mixed', 'from'=>'mixed', 'to'=>'mixed'], 'XMLDiff\Base::merge' => ['mixed', 'src'=>'mixed', 'diff'=>'mixed'], From 22f1ea89282706982f658f7907dfcfb5204393fb Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sat, 23 Aug 2025 22:18:52 +0200 Subject: [PATCH 2/2] Test --- .../CallToFunctionParametersRuleTest.php | 5 +++ .../PHPStan/Rules/Functions/data/bug-9970.php | 39 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/PHPStan/Rules/Functions/data/bug-9970.php diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 89bcfafeee..9a9cc2f6e5 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -2295,6 +2295,11 @@ public function testBug5760(): void ]); } + public function testBug9970(): void + { + $this->analyse([__DIR__ . '/data/bug-9970.php'], []); + } + #[RequiresPhp('>= 8.0')] public function testBug12317(): void { diff --git a/tests/PHPStan/Rules/Functions/data/bug-9970.php b/tests/PHPStan/Rules/Functions/data/bug-9970.php new file mode 100644 index 0000000000..8aa447e2f4 --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-9970.php @@ -0,0 +1,39 @@ +dummy = "b"; + throw new \Exception("ex"); + } + + function endHandler($XmlParser, $tag) + { + } +} + +$p1 = new Xml_Parser(); +try { + $p1->parse(''); + echo "Exception swallowed\n"; +} catch (\Exception $e) { + echo "OK\n"; +}