Esempio n. 1
0
 public function addImplementor(AbstractUnitObject $unit)
 {
     if ($this->getRootNode()->queryOne(sprintf('phpdox:implementor[@full = "%s"]', $unit->getName())) !== NULL) {
         return;
     }
     $implementor = $this->getRootNode()->appendElementNS(self::XMLNS, 'implementor');
     $this->setName($unit->getName(), $implementor);
 }
Esempio n. 2
0
 private function processProperty(NodeType\Property $node)
 {
     $property = $node->props[0];
     $member = $this->unit->addMember($property->name);
     $this->setVariableType($member, $property->type);
     $this->setVariableDefaultValue($member, $property->default);
     $visibility = 'public';
     if ($node->isPrivate()) {
         $visibility = 'private';
     } elseif ($node->isProtected()) {
         $visibility = 'protected';
     }
     $member->setVisibility($visibility);
     $docComment = $node->getDocComment();
     if ($docComment !== NULL) {
         $block = $this->docBlockParser->parse($docComment, $this->aliasMap);
         $member->setDocBlock($block);
     }
     $member->setLine($node->getLine());
 }
Esempio n. 3
0
 private function addUnresolved(AbstractUnitObject $unit, $missingUnit)
 {
     $unitName = $unit->getName();
     if (isset($this->unresolved[$unitName])) {
         if (!is_array($this->unresolved[$unitName])) {
             $this->unresolved[$unitName] = array($this->unresolved[$unitName]);
         }
         $this->unresolved[$unitName][] = $missingUnit;
     } else {
         $this->unresolved[$unitName] = $missingUnit;
     }
     $unit->markDependencyAsUnresolved($missingUnit);
     $this->project->registerForSaving($unit);
 }
Esempio n. 4
0
 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);
         }
     }
 }
Esempio n. 5
0
 /**
  * @param AbstractUnitObject $unit
  */
 private function addUnit(AbstractUnitObject $unit, $type)
 {
     $root = $this->getRootElement();
     if (!$this->findUnitNodeByName($unit->getNamespace(), $unit->getLocalName())) {
         $unitNode = $root->appendElementNS('http://xml.phpdox.net/src', $type);
         $unitNode->setAttribute('name', $unit->getLocalName());
         $src = $unit->getSourceFilename();
         if ($src != '') {
             $unitNode->setAttribute('src', $src->getRelative($this->srcDir, FALSE));
         }
         $desc = $unit->getCompactDescription();
         if ($desc != '') {
             $unitNode->setAttribute('description', $desc);
         }
         $xpath = 'phpdox:namespace[@name="' . $unit->getNamespace() . '"]';
         $ctx = $root->queryOne($xpath);
         if (!$ctx) {
             $ctx = $root->appendElementNS('http://xml.phpdox.net/src', 'namespace');
             $ctx->setAttribute('name', $unit->getNamespace());
         }
         $ctx->appendChild($unitNode);
     }
 }
Esempio n. 6
0
 private function addUnresolved(AbstractUnitObject $unit, $missingUnit)
 {
     $unitName = $unit->getName();
     if (!isset($this->unresolved[$unitName])) {
         $this->unresolved[$unitName] = array();
     }
     $this->unresolved[$unitName][] = $missingUnit;
     $this->project->registerForSaving($unit);
 }
Esempio n. 7
0
 public function registerForSaving(AbstractUnitObject $unit)
 {
     $this->saveUnits[$unit->getName()] = $unit;
 }
Esempio n. 8
0
 private function saveUnit(array $map, array $reportUnits, AbstractUnitObject $unit)
 {
     $indexNode = $this->index->findUnitNodeByName($unit->getNamespace(), $unit->getLocalName());
     if (!$indexNode) {
         throw new ProjectException(sprintf("Internal Error: Unit '%s' not found in index (ns: %s, n: %s).", $unit->getName(), $unit->getNamespace(), $unit->getLocalName()), ProjectException::UnitNotFoundInIndex);
     }
     $name = str_replace('\\', '_', $unit->getName());
     $dom = $unit->export();
     $dom->formatOutput = TRUE;
     $dom->preserveWhiteSpace = FALSE;
     $fname = $map[$dom->documentElement->localName] . '/' . $name . '.xml';
     try {
         $dom->save($this->xmlDir . '/' . $fname);
     } catch (fDOMException $e) {
         throw new ProjectException(sprintf("Internal Error: Unit '%s' could not be saved (ns: %s, n: %s).", $unit->getName(), $unit->getNamespace(), $unit->getLocalName()), ProjectException::UnitCouldNotBeSaved, $e);
     }
     if ($indexNode->hasAttribute('xml')) {
         $reportUnits = array_merge($reportUnits, $this->findAffectedUnits($fname));
     } else {
         $indexNode->setAttribute('xml', $fname);
     }
     return $reportUnits;
 }
Esempio n. 9
0
        /**
         * @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);
                    }
                }
            }
        }