Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deprecation warning on PHP 8.4 with xml_set_object() #130

Merged
merged 1 commit into from
Feb 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions src/nusoap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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'];
Expand Down