private function processTraitUse(AbstractUnitObject $unit, TraitUseObject $use, AbstractUnitObject $trait) { $this->project->registerForSaving($unit); $this->project->registerForSaving($trait); $trait->addUser($unit); $unit->importTraitExports($trait, $use); if ($trait->hasExtends()) { foreach ($trait->getExtends() as $name) { try { $extendedUnit = $this->getUnitByName($name); $this->processExtends($unit, $extendedUnit, $extendedUnit); } catch (ProjectException $e) { $this->addUnresolved($unit, $trait->getExtends()); } } } if ($trait->usesTraits()) { foreach ($trait->getUsedTraits() as $traitName) { try { $traitUnit = $this->getUnitByName($traitName); $this->processTraitUse($unit, $trait->getTraitUse($traitName), $traitUnit); } catch (ProjectException $e) { $this->addUnresolved($unit, $traitName); } } } }
/** * @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); } }
private function processImplements(AbstractUnitObject $unit, AbstractUnitObject $implements) { $this->project->registerForSaving($unit); $this->project->registerForSaving($implements); $implements->addImplementor($unit); $unit->importExports($implements, 'interface'); if ($implements->hasImplements()) { foreach ($implements->getImplements() as $implementing) { try { $implementsUnit = $this->getUnitByName($implementing); $this->processExtends($unit, $implementsUnit, $implementsUnit); } catch (ProjectException $e) { $this->addUnresolved($unit->getName(), $implementing); } } } }