コード例 #1
0
 /**
  * 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 \phpDocumentor\Reflection\ClassReflection $class  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, $class, \DOMElement $child = null)
 {
     if (!$child) {
         $child = new \DOMElement('class');
         $parent->appendChild($child);
     }
     $child->setAttribute('final', $class->isFinal() ? 'true' : 'false');
     $child->setAttribute('abstract', $class->isAbstract() ? 'true' : 'false');
     $object = new InterfaceExporter();
     $object->export($child, $class, $child);
 }
コード例 #2
0
 /**
  * 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 \phpDocumentor\Reflection\ClassReflection $class  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, $class, \DOMElement $child = null)
 {
     if (!$child) {
         $child = new \DOMElement('class');
         $parent->appendChild($child);
     }
     $child->setAttribute('final', $class->isFinal() ? 'true' : 'false');
     $child->setAttribute('abstract', $class->isAbstract() ? 'true' : 'false');
     $child->appendChild(new \DOMElement('extends', $class->getParentClass()));
     $interfaces = method_exists($class, 'getInterfaces') ? $class->getInterfaces() : $class->getParentInterfaces();
     foreach ($interfaces as $interface) {
         $child->appendChild(new \DOMElement('implements', $interface));
     }
     $object = new InterfaceExporter();
     $object->export($child, $class, $child);
 }
コード例 #3
0
 /**
  * Export the given file to the provided parent element.
  *
  * @param \DOMElement                    $parent Element to augment.
  * @param \phpDocumentor\Reflection\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()))));
     }
 }