addTrait() public method

public addTrait ( TraitObject $trait )
$trait TraitObject
Example #1
0
 /**
  * @param FileInfo $file
  *
  * @throws CollectorException
  * @throws \TheSeer\phpDox\ProgressLoggerException
  *
  * @return bool
  */
 private function processFile(SourceFile $file)
 {
     try {
         if ($file->getSize() === 0) {
             $this->logger->progress('processed');
             return true;
         }
         $result = $this->backend->parse($file);
         if ($result->hasClasses()) {
             foreach ($result->getClasses() as $class) {
                 $this->project->addClass($class);
             }
         }
         if ($result->hasInterfaces()) {
             foreach ($result->getInterfaces() as $interface) {
                 $this->project->addInterface($interface);
             }
         }
         if ($result->hasTraits()) {
             foreach ($result->getTraits() as $trait) {
                 $this->project->addTrait($trait);
             }
         }
         $this->logger->progress('processed');
         return true;
     } catch (ParseErrorException $e) {
         $this->parseErrors[$file->getPathname()] = $e->getPrevious()->getMessage();
         $this->logger->progress('failed');
         return false;
     } catch (\Exception $e) {
         throw new CollectorException('Error while processing source file', CollectorException::ProcessingError, $e, $file);
     }
 }