diff --git a/resources/functionMap.php b/resources/functionMap.php index e1efc645b5..79addae36f 100644 --- a/resources/functionMap.php +++ b/resources/functionMap.php @@ -11717,16 +11717,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'], diff --git a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php index 45e6e9fdfd..94416a45cd 100644 --- a/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php +++ b/tests/PHPStan/Rules/Functions/CallToFunctionParametersRuleTest.php @@ -2199,6 +2199,11 @@ public function testBug3506(): void $this->analyse([__DIR__ . '/data/bug-3506.php'], []); } + 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"; +}