From a9dbecb4a370919a7f19456549c16e81253e3760 Mon Sep 17 00:00:00 2001 From: macbre Date: Fri, 4 Aug 2023 16:57:25 +0100 Subject: [PATCH] XMLParser: add $isFinal variable --- src/XMLParser.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/XMLParser.php b/src/XMLParser.php index 38d78ff..5f387f4 100644 --- a/src/XMLParser.php +++ b/src/XMLParser.php @@ -143,7 +143,9 @@ private function parseNextChunk(): void { // the nodes stack has been iterated over, consume and parse the next piece of the XML stream $data = stream_get_contents($this->stream, length: self::BATCH_READ_SIZE); - $res = xml_parse($this->parser, $data, is_final: $data === false); + $isFinal = ($data === false); + + $res = xml_parse($this->parser, $data, $isFinal); if ($res === 0 /* returns 0 on failure */) { // take more details from the parser instance and throw an exception @@ -151,7 +153,7 @@ private function parseNextChunk(): void } // we're done with reading and parsing the stream, close the XML parser instance - if ($data === false) { + if ($isFinal) { $this->close(); } }