/**
  * Export this interface definition to the given parent DOMElement.
  *
  * @param \DOMElement        $parent    Element to augment.
  * @param InterfaceReflector $interface Element to log export.
  * @param \DOMElement        $child     if supplied this element will be
  *     augmented instead of freshly added.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $interface, \DOMElement $child = null)
 {
     if ($child === null) {
         $child = new \DOMElement('interface');
         $parent->appendChild($child);
     }
     $child->setAttribute('namespace', $interface->getNamespace());
     $child->setAttribute('line', $interface->getLineNumber());
     $short_name = method_exists($interface, 'getShortName') ? $interface->getShortName() : $interface->getName();
     $child->appendChild(new \DOMElement('name', $short_name));
     $child->appendChild(new \DOMElement('full_name', $interface->getName()));
     foreach ($interface->getParentInterfaces() as $parent_interface) {
         $child->appendChild(new \DOMElement('extends', $parent_interface));
     }
     $object = new DocBlockExporter();
     $object->export($child, $interface);
     foreach ($interface->getConstants() as $constant) {
         $object = new ConstantExporter();
         $constant->setDefaultPackageName($interface->getDefaultPackageName());
         $object->export($child, $constant);
     }
     foreach ($interface->getProperties() as $property) {
         $object = new PropertyExporter();
         $property->setDefaultPackageName($interface->getDefaultPackageName());
         $object->export($child, $property);
     }
     foreach ($interface->getMethods() as $method) {
         $object = new MethodExporter();
         $method->setDefaultPackageName($interface->getDefaultPackageName());
         $object->export($child, $method);
     }
 }
 /**
  * Export the given include definition to the provided parent element.
  *
  * @param \DOMElement      $parent  Element to augment.
  * @param IncludeReflector $include Element to export.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $include)
 {
     $child = new \DOMElement('include');
     $parent->appendChild($child);
     $child->setAttribute('line', $include->getLineNumber());
     $child->setAttribute('type', $include->getType());
     $child->appendChild(new \DOMElement('name', $include->getName()));
     $object = new DocBlockExporter();
     $object->export($child, $include);
 }
 /**
  * Export this variable definition to the given parent DOMElement.
  *
  * @param \DOMElement       $parent   Element to augment.
  * @param PropertyReflector $variable Element to log from.
  * @param \DOMElement       $child    if supplied this element will be
  *     augmented instead of freshly added.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $variable, \DOMElement $child = null)
 {
     if (!$child) {
         $child = new \DOMElement('variable');
         $parent->appendChild($child);
     }
     $child->setAttribute('line', $variable->getLineNumber());
     $child->setAttribute('namespace', $variable->getNamespace() ? $variable->getNamespace() : $parent->getAttribute('namespace'));
     $child->appendChild(new \DOMElement('name', $variable->getName()));
     $child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText($variable->getDefault()));
     $object = new DocBlockExporter();
     $object->export($child, $variable);
 }
 /**
  * Export this variable definition to the given parent DOMElement.
  *
  * @param \DOMElement       $parent   Element to augment.
  * @param PropertyReflector $variable Element to log from.
  * @param \DOMElement       $child    if supplied this element will be
  *     augmented instead of freshly added.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $variable, \DOMElement $child = null)
 {
     if (!$child) {
         $child = new \DOMElement('variable');
         $parent->appendChild($child);
     }
     $child->setAttribute('line', $variable->getLineNumber());
     $child->setAttribute('namespace', $variable->getNamespace() ? $variable->getNamespace() : $parent->getAttribute('namespace'));
     $child->appendChild(new \DOMElement('name', $variable->getName()));
     $default = new \DOMElement('default');
     $child->appendChild($default);
     /** @var \DOMDocument $dom_document */
     $dom_document = $child->ownerDocument;
     $default->appendChild($dom_document->createCDATASection($variable->getDefault()));
     $object = new DocBlockExporter();
     $object->export($child, $variable);
 }
 /**
  * Exports the given reflection object to the parent XML element.
  *
  * This method creates a new child element on the given parent XML element
  * and takes the properties of the Reflection argument and sets the
  * elements and attributes on the child.
  *
  * If a child DOMElement is provided then the properties and attributes are
  * set on this but the child element is not appended onto the parent. This
  * is the responsibility of the invoker. Essentially this means that the
  * $parent argument is ignored in this case.
  *
  * @param \DOMElement       $parent   The parent element to augment.
  * @param ConstantReflector $constant The data source.
  * @param \DOMElement       $child    Optional: child element to use
  *     instead of creating a new one on the $parent.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $constant, \DOMElement $child = null)
 {
     if (!$constant->getName()) {
         return;
     }
     if (!$child) {
         $child = new \DOMElement('constant');
         $parent->appendChild($child);
     }
     $child->setAttribute('namespace', $constant->getNamespace() ? $constant->getNamespace() : $parent->getAttribute('namespace'));
     $child->setAttribute('line', $constant->getLineNumber());
     $short_name = method_exists($constant, 'getShortName') ? $constant->getShortName() : $constant->getName();
     $child->appendChild(new \DOMElement('name', $short_name));
     $child->appendChild(new \DOMElement('full_name', $constant->getName()));
     $child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue()));
     $object = new DocBlockExporter();
     $constant->setDefaultPackageName($parent->getAttribute('package'));
     $object->export($child, $constant);
 }
 /**
  * Export this function definition to the given parent DOMElement.
  *
  * @param \DOMElement       $parent   Element to augment.
  * @param FunctionReflector $function Element to export.
  * @param \DOMElement       $child    if supplied this element will be
  *     augmented instead of freshly added.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $function, \DOMElement $child = null)
 {
     if (!$child) {
         $child = new \DOMElement('function');
         $parent->appendChild($child);
     }
     $child->setAttribute('namespace', $function->getNamespace() ? $function->getNamespace() : $parent->getAttribute('namespace'));
     $child->setAttribute('line', $function->getLineNumber());
     $short_name = method_exists($function, 'getShortName') ? $function->getShortName() : $function->getName();
     $child->appendChild(new \DOMElement('name', $short_name));
     $child->appendChild(new \DOMElement('full_name', $function->getName()));
     $object = new DocBlockExporter();
     $function->setDefaultPackageName($parent->getAttribute('package'));
     $object->export($child, $function);
     foreach ($function->getArguments() as $argument) {
         $object = new ArgumentExporter();
         $object->export($child, $argument);
     }
 }
 /**
  * Export the given file to the provided parent element.
  *
  * @param \DOMElement   $parent Element to augment.
  * @param FileReflector $file   Element to export.
  *
  * @return void
  */
 public function export(\DOMElement $parent, $file)
 {
     $child = new \DOMElement('file');
     $parent->appendChild($child);
     $child->setAttribute('path', ltrim($file->getFilename(), './'));
     $child->setAttribute('hash', $file->getHash());
     $object = new DocBlockExporter();
     $object->export($child, $file);
     // add namespace aliases
     foreach ($file->getNamespaceAliases() as $alias => $namespace) {
         $alias_obj = new \DOMElement('namespace-alias', $namespace);
         $child->appendChild($alias_obj);
         $alias_obj->setAttribute('name', $alias);
     }
     /** @var \phpDocumentor\Reflection\IncludeReflector $include */
     foreach ($file->getIncludes() as $include) {
         $include->setDefaultPackageName($file->getDefaultPackageName());
         $object = new IncludeExporter();
         $object->export($child, $include);
     }
     /** @var \phpDocumentor\Reflection\ConstantReflector $constant */
     foreach ($file->getConstants() as $constant) {
         $constant->setDefaultPackageName($file->getDefaultPackageName());
         $object = new ConstantExporter();
         $object->export($child, $constant);
     }
     /** @var \phpDocumentor\Reflection\FunctionReflector $function */
     foreach ($file->getFunctions() as $function) {
         $function->setDefaultPackageName($file->getDefaultPackageName());
         $object = new FunctionExporter();
         $object->export($child, $function);
     }
     /** @var \phpDocumentor\Reflection\InterfaceReflector $interface */
     foreach ($file->getInterfaces() as $interface) {
         $interface->setDefaultPackageName($file->getDefaultPackageName());
         $object = new InterfaceExporter();
         $object->export($child, $interface);
     }
     /** @var \phpDocumentor\Reflection\ClassReflector $class */
     foreach ($file->getClasses() as $class) {
         $class->setDefaultPackageName($file->getDefaultPackageName());
         $object = new ClassExporter();
         $object->export($child, $class);
     }
     // add markers
     if (count($file->getMarkers()) > 0) {
         $markers = new \DOMElement('markers');
         $child->appendChild($markers);
         foreach ($file->getMarkers() as $marker) {
             $marker_obj = new \DOMElement(strtolower($marker[0]), htmlspecialchars(trim($marker[1])));
             $markers->appendChild($marker_obj);
             $marker_obj->setAttribute('line', $marker[2]);
         }
     }
     if (count($file->getParseErrors()) > 0) {
         $parse_errors = new \DOMElement('parse_markers');
         $child->appendChild($parse_errors);
         foreach ($file->getParseErrors() as $error) {
             $marker_obj = new \DOMElement(strtolower($error[0]), htmlspecialchars(trim($error[1])));
             $parse_errors->appendChild($marker_obj);
             $marker_obj->setAttribute('line', $error[2]);
             $marker_obj->setAttribute('code', $error[3]);
         }
     }
     // if we want to include the source for each file; append a new
     // element 'source' which contains a compressed, encoded version
     // of the source
     if ($this->include_source) {
         $child->appendChild(new \DOMElement('source', base64_encode(gzcompress($file->getContents()))));
     }
 }