private function endArray() { $popped = array_pop($this->stack); if ($popped !== self::STACK_ARRAY) { throw new ParsingError($this->lineNumber, $this->charNumber, "Unexpected end of array encountered."); } $this->listener->onArrayEnd(); $this->state = self::STATE_AFTER_VALUE; if (empty($this->stack)) { $this->endDocument(); } }