protected function checkStartDocument($data) { if (count($this->stack)) { throw new Exceptions\OutputGeneratorException('Starting a document may only be the very first operation.'); } $this->stack[] = array('document', $data, array()); }