/** * @covers phpDocumentor\Descriptor\DescriptorAbstract::setNamespace * @covers phpDocumentor\Descriptor\DescriptorAbstract::getNamespace */ public function testSettingAndGettingNamespace() { $this->assertNull($this->fixture->getNamespace()); $mock = m::mock('phpDocumentor\\Descriptor\\NamespaceDescriptor'); $this->fixture->setNamespace($mock); $this->assertSame($mock, $this->fixture->getNamespace()); }
/** * Overrides the name and namespace of an element with a separated version of the class name. * * If a class is separated by underscores than the last part is set as name and the first parts are set as * namespace with the namespace separator instead of an underscore. * * @param DescriptorAbstract $value * * @return DescriptorAbstract|null */ public function filter($value) { if ($value) { $namespace = $value->getNamespace() == '' ? '\\' . $this->namespacePrefix : $value->getNamespace(); $value->setNamespace($this->namespaceFromLegacyNamespace($namespace, $value->getName())); $value->setName($this->classNameFromLegacyNamespace($value->getName())); } return $value; }
/** * Normalizes the given FQSEN as if the context marker represents a class/interface/trait as parent. * * @param string $fqsen * @param DescriptorAbstract $container * * @return string */ protected function getTypeWithNamespaceAsContext($fqsen, DescriptorAbstract $container) { $namespace = $container instanceof NamespaceDescriptor ? $container : $container->getNamespace(); $fqnn = $namespace instanceof NamespaceDescriptor ? $namespace->getFullyQualifiedStructuralElementName() : $namespace; return str_replace(self::CONTEXT_MARKER . '::', $fqnn . '\\', $fqsen); }
/** * Creates a DocBlock context containing the namespace and aliases for the current descriptor. * * @return Context */ private function createDocBlockContext() { $file = $this->descriptor->getFile(); $namespaceAliases = $file ? $file->getNamespaceAliases()->getAll() : array(); return new Context($this->descriptor->getNamespace(), $namespaceAliases); }