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