public function importTraitExports(AbstractUnitObject $trait, TraitUseObject $use) { $container = $this->rootNode->queryOne(sprintf('phpdox:trait[@full="%s"]', $trait->getName())); if ($container instanceof fDOMElement) { $container->parentNode->removeChild($container); } $container = $this->rootNode->appendElementNS(self::XMLNS, 'trait'); $this->setName($trait->getName(), $container); if ($trait->hasExtends()) { foreach ($trait->getExtends() as $name) { $extends = $container->appendElementNS(self::XMLNS, 'extends'); $this->setName($name, $extends); } } if ($trait->usesTraits()) { foreach ($trait->getUsedTraits() as $name) { $used = $container->appendElementNS(self::XMLNS, 'uses'); $this->setName($name, $used); } } foreach ($trait->getConstants() as $constant) { $container->appendChild($this->dom->importNode($constant->export(), TRUE)); } foreach ($trait->getExportedMembers() as $member) { $memberNode = $this->dom->importNode($member->export(), TRUE); $this->adjustStaticResolution($memberNode); $container->appendChild($memberNode); } foreach ($trait->getExportedMethods() as $method) { $methodName = $method->getName(); $methodNode = $this->dom->importNode($method->export(), TRUE); if (!$use->isExcluded($methodName)) { $container->appendChild($methodNode); } $this->adjustStaticResolution($methodNode); $aliasNode = NULL; if ($use->isAliased($methodName)) { $aliasNode = $methodNode->cloneNode(true); $aliasNode->setAttribute('original', $aliasNode->getAttribute('name')); $aliasNode->setAttribute('name', $use->getAliasedName($methodName)); if ($use->hasAliasedModifier($methodName)) { $aliasNode->setAttribute('visibility', $use->getAliasedModifier($methodName)); } $container->appendChild($aliasNode); } } }
/** * @param AbstractUnitObject $unit */ public function importExports(AbstractUnitObject $unit, $container = 'parent') { $parent = $this->rootNode->queryOne(sprintf('//phpdox:%s[@full="%s"]', $container, $unit->getName())); if ($parent instanceof fDOMElement) { $parent->parentNode->removeChild($parent); } $parent = $this->rootNode->appendElementNS( self::XMLNS, $container); $parent->setAttribute('full', $unit->getName()); $parent->setAttribute('namespace', $unit->getNamespace()); $parent->setAttribute('name', $unit->getLocalName()); if ($unit->hasExtends()) { foreach($unit->getExtends() as $name) { $extends = $parent->appendElementNS( self::XMLNS, 'extends'); $this->setName($name, $extends); } } foreach($unit->getConstants() as $constant) { $parent->appendChild( $this->dom->importNode($constant->export(), TRUE) ); } foreach($unit->getExportedMembers() as $member) { $parent->appendChild( $this->dom->importNode($member->export(), TRUE) ); } foreach($unit->getExportedMethods() as $method) { $methodNode = $this->dom->importNode($method->export(), TRUE); $parent->appendChild( $methodNode ); if ($this->hasMethod($method->getName())) { $unitMethod = $this->getMethod($method->getName()); if ($unitMethod->hasInheritDoc()) { $unitMethod->inhertDocBlock($method); } } } }