From e056d13cf36f97a2682261944a6a5b0b2948eff9 Mon Sep 17 00:00:00 2001 From: Fab Stz Date: Fri, 7 Feb 2025 14:06:04 +0100 Subject: [PATCH] fix deprecation warning on PHP 8.4 with xml_set_object() RuntimeException: Function xml_set_object() is deprecated since 8.4, provide a proper method callable to xml_set_*_handler() functions on line 6808 in file vendor/econea/nusoap/src/nusoap.php --- src/nusoap.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/nusoap.php b/src/nusoap.php index 3100bbb..28e8b75 100644 --- a/src/nusoap.php +++ b/src/nusoap.php @@ -1242,16 +1242,13 @@ function parseString($xml, $type) // Set the options for parsing the XML data. xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); - // Set the object for the parser. - xml_set_object($this->parser, $this); - // Set the element handlers for the parser. if ($type == "schema") { - xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement'); - xml_set_character_data_handler($this->parser, 'schemaCharacterData'); + xml_set_element_handler($this->parser, [$this, 'schemaStartElement'], [$this, 'schemaEndElement']); + xml_set_character_data_handler($this->parser, [$this, 'schemaCharacterData']); } elseif ($type == "xml") { - xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement'); - xml_set_character_data_handler($this->parser, 'xmlCharacterData'); + xml_set_element_handler($this->parser, [$this, 'xmlStartElement'], [$this, 'xmlEndElement']); + xml_set_character_data_handler($this->parser, [$this, 'xmlCharacterData']); } // Parse the XML file. @@ -5002,11 +4999,9 @@ function parseWSDL($wsdl = '') // Set the options for parsing the XML data. // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); - // Set the object for the parser. - xml_set_object($this->parser, $this); // Set the element handlers for the parser. - xml_set_element_handler($this->parser, 'start_element', 'end_element'); - xml_set_character_data_handler($this->parser, 'character_data'); + xml_set_element_handler($this->parser, [$this, 'start_element'], [$this, 'end_element']); + xml_set_character_data_handler($this->parser, [$this, 'character_data']); // Parse the XML file. if (!xml_parse($this->parser, $wsdl_string, true)) { // Display an error message. @@ -6809,11 +6804,9 @@ function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = tru //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); - // Set the object for the parser. - xml_set_object($this->parser, $this); // Set the element handlers for the parser. - xml_set_element_handler($this->parser, 'start_element', 'end_element'); - xml_set_character_data_handler($this->parser, 'character_data'); + xml_set_element_handler($this->parser, [$this, 'start_element'], [$this, 'end_element']); + xml_set_character_data_handler($this->parser, [$this, 'character_data']); $parseErrors = array(); $chunkSize = 4096; for($pointer = 0; $pointer < strlen($xml) && empty($parseErrors); $pointer += $chunkSize) { @@ -6871,9 +6864,8 @@ function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = tru $this->parser = xml_parser_create($this->xml_encoding); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); - xml_set_object($this->parser, $this); - xml_set_element_handler($this->parser, 'start_element', 'end_element'); - xml_set_character_data_handler($this->parser, 'character_data'); + xml_set_element_handler($this->parser, [$this, 'start_element'], [$this, 'end_element']); + xml_set_character_data_handler($this->parser, [$this, 'character_data']); if(!empty($attachment['content'])) { $content = $attachment['content'];