コード例 #1
0
 /**
  * Generates a URL from the given node or returns false if unable.
  *
  * @param \phpDocumentor\Descriptor\ConstantDescriptor $node
  *
  * @return string|false
  */
 public function __invoke($node)
 {
     $name = $node->getName();
     // global constant
     if ($node->getParent() instanceof \phpDocumentor\Descriptor\FileDescriptor || !$node->getParent()) {
         $namespaceName = $node->getNamespace();
         return '/namespaces/' . str_replace('\\', '.', ltrim($namespaceName, '\\')) . '.html#constant_' . $name;
     }
     // class constant
     $className = $node->getParent()->getFullyQualifiedStructuralElementName();
     return '/classes/' . str_replace('\\', '.', ltrim($className, '\\')) . '.html#constant_' . $name;
 }
コード例 #2
0
 /**
  * @covers phpDocumentor\Descriptor\DescriptorAbstract::getCopyright
  */
 public function testCopyrightTagsInheritWhenNoneArePresent()
 {
     // Arrange
     $copyrightTagDescriptor = new TagDescriptor('copyright');
     $copyrightCollection = new Collection(array($copyrightTagDescriptor));
     $this->fixture->getTags()->clear();
     $parentProperty = $this->whenFixtureHasConstantInParentClassWithSameName($this->fixture->getName());
     $parentProperty->getTags()->set('copyright', $copyrightCollection);
     // Act
     $result = $this->fixture->getCopyright();
     // Assert
     $this->assertSame($copyrightCollection, $result);
 }
コード例 #3
0
 /**
  * Export the given reflected constant definition to the provided parent element.
  *
  * @param \DOMElement        $parent Element to augment.
  * @param ConstantDescriptor $constant Element to export.
  *
  * @return \DOMElement
  */
 public function convert(\DOMElement $parent, ConstantDescriptor $constant)
 {
     $fullyQualifiedNamespaceName = $constant->getNamespace() instanceof NamespaceDescriptor ? $constant->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace');
     $child = new \DOMElement('constant');
     $parent->appendChild($child);
     $child->setAttribute('namespace', ltrim($fullyQualifiedNamespaceName, '\\'));
     $child->setAttribute('line', $constant->getLine());
     $child->appendChild(new \DOMElement('name', $constant->getName()));
     $child->appendChild(new \DOMElement('full_name', $constant->getFullyQualifiedStructuralElementName()));
     $child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue()));
     $this->docBlockConverter->convert($child, $constant);
     return $child;
 }
コード例 #4
0
ファイル: Xml.php プロジェクト: michaelyin1/Modern-Toolkit
 /**
  * Exports the given constant 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 ConstantDescriptor $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 buildConstant(\DOMElement $parent, ConstantDescriptor $constant, \DOMElement $child = null)
 {
     if (!$constant->getName()) {
         return;
     }
     if (!$child) {
         $child = new \DOMElement('constant');
         $parent->appendChild($child);
     }
     $namespace = $constant->getNamespace() ? $constant->getNamespace() : $parent->getAttribute('namespace');
     $child->setAttribute('namespace', ltrim($namespace, '\\'));
     $child->setAttribute('line', $constant->getLine());
     $child->appendChild(new \DOMElement('name', $constant->getName()));
     $child->appendChild(new \DOMElement('full_name', $constant->getFullyQualifiedStructuralElementName()));
     $child->appendChild(new \DOMElement('value'))->appendChild(new \DOMText($constant->getValue()));
     $this->buildDocBlock($child, $constant);
 }