/**
  * Export the given reflected Trait definition to the provided parent 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 Element to augment.
  * @param TraitDescriptor $trait Element to export.
  *
  * @return \DOMElement
  */
 public function convert(\DOMElement $parent, TraitDescriptor $trait)
 {
     $child = new \DOMElement('trait');
     $parent->appendChild($child);
     $namespace = $trait->getNamespace()->getFullyQualifiedStructuralElementName();
     $child->setAttribute('namespace', ltrim($namespace, '\\'));
     $child->setAttribute('line', $trait->getLine());
     $child->appendChild(new \DOMElement('name', $trait->getName()));
     $child->appendChild(new \DOMElement('full_name', $trait->getFullyQualifiedStructuralElementName()));
     $this->docBlockConverter->convert($child, $trait);
     foreach ($trait->getProperties() as $property) {
         $this->propertyConverter->convert($child, $property);
     }
     foreach ($trait->getMethods() as $method) {
         $this->methodConverter->convert($child, $method);
     }
     return $child;
 }
 /**
  * @param ClassDescriptor|TraitDescriptor $parent
  */
 public function setParent($parent)
 {
     $this->setFullyQualifiedStructuralElementName($parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName());
     $this->parent = $parent;
 }
Beispiel #3
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 ClassDescriptor $trait  The data source.
  * @param \DOMElement     $child  Optional: child element to use instead of creating a
  *      new one on the $parent.
  *
  * @return void
  */
 public function buildTrait(\DOMElement $parent, TraitDescriptor $trait, \DOMElement $child = null)
 {
     if (!$child) {
         $child = new \DOMElement('trait');
         $parent->appendChild($child);
     }
     $child->setAttribute('final', $trait->isFinal() ? 'true' : 'false');
     $child->setAttribute('abstract', $trait->isAbstract() ? 'true' : 'false');
     $namespace = $trait->getNamespace();
     $child->setAttribute('namespace', ltrim($namespace, '\\'));
     $child->setAttribute('line', $trait->getLine());
     $child->appendChild(new \DOMElement('name', $trait->getName()));
     $child->appendChild(new \DOMElement('full_name', $trait->getFullyQualifiedStructuralElementName()));
     $this->buildDocBlock($child, $trait);
     foreach ($trait->getProperties() as $property) {
         $this->buildProperty($child, $property);
     }
     foreach ($trait->getMethods() as $method) {
         $this->buildMethod($child, $method);
     }
 }