/**
  * Creates a Descriptor from the provided data.
  *
  * @param FileReflector $data
  *
  * @return FileDescriptor
  */
 public function create($data)
 {
     $fileDescriptor = new FileDescriptor($data->getHash());
     $fileDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: $data->getDefaultPackageName());
     $packages = new Collection();
     $package = $this->extractPackageFromDocBlock($data->getDocBlock());
     if (!$package) {
         $package = $data->getDefaultPackageName();
     }
     $tag = new TagDescriptor('package');
     $tag->setDescription($package);
     $packages->add($tag);
     $fileDescriptor->getTags()->set('package', $packages);
     $fileDescriptor->setName(basename($data->getFilename()));
     $fileDescriptor->setPath($data->getFilename());
     $fileDescriptor->setSource($data->getContents());
     $fileDescriptor->setIncludes(new Collection($data->getIncludes()));
     $fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaceAliases()));
     $this->assembleDocBlock($data->getDocBlock(), $fileDescriptor);
     $this->addMarkers($data->getMarkers(), $fileDescriptor);
     $this->addConstants($data->getConstants(), $fileDescriptor);
     $this->addFunctions($data->getFunctions(), $fileDescriptor);
     $this->addClasses($data->getClasses(), $fileDescriptor);
     $this->addInterfaces($data->getInterfaces(), $fileDescriptor);
     $this->addTraits($data->getTraits(), $fileDescriptor);
     return $fileDescriptor;
 }
Esempio n. 2
0
 /**
  * Creates a Descriptor from the provided data.
  *
  * @param FileReflector $data
  *
  * @return FileDescriptor
  */
 public function create($data)
 {
     $fileDescriptor = new FileDescriptor($data->getHash());
     $fileDescriptor->setPackage($this->extractPackageFromDocBlock($data->getDocBlock()) ?: $data->getDefaultPackageName());
     $fileDescriptor->setName(basename($data->getFilename()));
     $fileDescriptor->setPath($data->getFilename());
     $fileDescriptor->setSource($data->getContents());
     $fileDescriptor->setIncludes(new Collection($data->getIncludes()));
     $fileDescriptor->setNamespaceAliases(new Collection($data->getNamespaceAliases()));
     $this->assembleDocBlock($data->getDocBlock(), $fileDescriptor);
     $this->overridePackageTag($data, $fileDescriptor);
     $this->addMarkers($data->getMarkers(), $fileDescriptor);
     $this->addConstants($data->getConstants(), $fileDescriptor);
     $this->addFunctions($data->getFunctions(), $fileDescriptor);
     $this->addClasses($data->getClasses(), $fileDescriptor);
     $this->addInterfaces($data->getInterfaces(), $fileDescriptor);
     $this->addTraits($data->getTraits(), $fileDescriptor);
     return $fileDescriptor;
 }
 /**
  * @covers phpDocumentor\Descriptor\FileDescriptor::setSource
  * @covers phpDocumentor\Descriptor\FileDescriptor::getSource
  */
 public function testSetAndGetSource()
 {
     $this->assertSame(null, $this->fixture->getSource());
     $this->fixture->setSource(self::EXAMPLE_SOURCE);
     $this->assertSame(self::EXAMPLE_SOURCE, $this->fixture->getSource());
 }