Пример #1
0
 /**
  * Creates a Descriptor from the provided data.
  *
  * @param ClassReflector $data
  *
  * @return ClassDescriptor
  */
 public function create($data)
 {
     $classDescriptor = new ClassDescriptor();
     $classDescriptor->setFullyQualifiedStructuralElementName($data->getName());
     $classDescriptor->setName($data->getShortName());
     $classDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: '');
     $classDescriptor->setLine($data->getLinenumber());
     $classDescriptor->setParent($data->getParentClass());
     $classDescriptor->setAbstract($data->isAbstract());
     $classDescriptor->setFinal($data->isFinal());
     // Reflection library formulates namespace as global but this is not wanted for phpDocumentor itself
     $classDescriptor->setNamespace('\\' . (strtolower($data->getNamespace()) == 'global' ? '' : $data->getNamespace()));
     foreach ($data->getInterfaces() as $interfaceClassName) {
         $classDescriptor->getInterfaces()->set($interfaceClassName, $interfaceClassName);
     }
     $fqcn = $classDescriptor->getFullyQualifiedStructuralElementName();
     $namespace = substr($fqcn, 0, strrpos($fqcn, '\\'));
     $classDescriptor->setNamespace($namespace);
     $this->assembleDocBlock($data->getDocBlock(), $classDescriptor);
     $this->addConstants($data->getConstants(), $classDescriptor);
     $this->addProperties($data->getProperties(), $classDescriptor);
     $this->addMethods($data->getMethods(), $classDescriptor);
     $this->addUses($data->getTraits(), $classDescriptor);
     return $classDescriptor;
 }
 /**
  * @covers phpDocumentor\Descriptor\ClassDescriptor::isFinal
  * @covers phpDocumentor\Descriptor\ClassDescriptor::setFinal
  */
 public function testSettingAndGettingWhetherClassIsFinal()
 {
     $this->assertFalse($this->fixture->isFinal());
     $this->fixture->setFinal(true);
     $this->assertTrue($this->fixture->isFinal());
 }