/** * Export the given reflected property definition to the provided parent element. * * @param \DOMElement $parent Element to augment. * @param PropertyDescriptor $property Element to export. * * @return \DOMElement */ public function convert(\DOMElement $parent, PropertyDescriptor $property) { $fullyQualifiedNamespaceName = $property->getNamespace() instanceof NamespaceDescriptor ? $property->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child = new \DOMElement('property'); $parent->appendChild($child); $child->setAttribute('static', var_export($property->isStatic(), true)); $child->setAttribute('visibility', $property->getVisibility()); $child->setAttribute('namespace', $fullyQualifiedNamespaceName); $child->setAttribute('line', $property->getLine()); $child->appendChild(new \DOMElement('name', '$' . $property->getName())); $child->appendChild(new \DOMElement('full_name', $property->getFullyQualifiedStructuralElementName())); $child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText($property->getDefault())); $this->docBlockConverter->convert($child, $property); return $child; }
/** * Export the given property definition to the provided parent element. * * @param \DOMElement $parent Element to augment. * @param PropertyDescriptor $property Element to export. * * @return void */ public function buildProperty(\DOMElement $parent, PropertyDescriptor $property) { $child = new \DOMElement('property'); $parent->appendChild($child); $child->setAttribute('static', $property->isStatic() ? 'true' : 'false'); $child->setAttribute('visibility', $property->getVisibility()); $child->setAttribute('line', $property->getLine()); $namespaceFqnn = $property->getNamespace() ? $property->getNamespace()->getFullyQualifiedStructuralElementName() : $parent->getAttribute('namespace'); $child->setAttribute('namespace', $namespaceFqnn); $child->appendChild(new \DOMElement('name', '$' . $property->getName())); $child->appendChild(new \DOMElement('default'))->appendChild(new \DOMText($property->getDefault())); $this->buildDocBlock($child, $property); }
/** * @covers phpDocumentor\Descriptor\PropertyDescriptor::getDefault * @covers phpDocumentor\Descriptor\PropertyDescriptor::setDefault */ public function testSetAndGetDefault() { $this->assertSame(null, $this->fixture->getDefault()); $this->fixture->setDefault('a'); $this->assertSame('a', $this->fixture->getDefault()); }