コード例 #1
0
ファイル: Collector.php プロジェクト: rocketpastsix/Autoload
 public function processFile(\SplFileInfo $file)
 {
     try {
         $parseResult = $this->parser->parse(new SourceFile($file->getRealpath()));
         if ($parseResult->hasRedeclarations() && !$this->tolerantMode) {
             throw new CollectorException(sprintf("Duplicate (potentially conditional) definitions of the following unit(s) found:\n\n\tUnit(s): %s\n\tFile: %s", join(', ', $parseResult->getRedeclarations()), $file->getRealPath()), CollectorException::InFileRedeclarationFound);
         }
         $this->collectorResult->addParseResult($file, $parseResult);
     } catch (ParserException $e) {
         throw new CollectorException(sprintf("Could not process file '%s' due to parse errors", $file->getRealPath()), CollectorException::ParseErrror, $e);
     } catch (CollectorResultException $e) {
         throw new CollectorException($e->getMessage(), CollectorException::RedeclarationFound);
     }
 }
コード例 #2
0
ファイル: Factory.php プロジェクト: theseer/autoload
 /**
  * Helper to get instance of AutoloadRenderer with cli options applied
  *
  * @param CollectorResult $result
  *
  * @throws \RuntimeException
  * @return \TheSeer\Autoload\AutoloadRenderer|\TheSeer\Autoload\StaticRenderer
  */
 public function getRenderer(CollectorResult $result)
 {
     $isStatic = $this->config->isStaticMode();
     $isPhar = $this->config->isPharMode();
     $isCompat = $this->config->isCompatMode();
     $isOnce = $this->config->isOnceMode();
     if ($isStatic === TRUE) {
         $renderer = new StaticRenderer($result->getUnits());
         $renderer->setDependencies($result->getDependencies());
         $renderer->setPharMode($isPhar);
         $renderer->setRequireOnce($isOnce);
     } else {
         $renderer = new AutoloadRenderer($result->getUnits());
         if ($this->config->usePrepend()) {
             $renderer->prependAutoloader();
         }
         if ($this->config->useExceptions()) {
             $renderer->enableExceptions();
         }
     }
     $renderer->setCompat($isCompat);
     $basedir = $this->config->getBaseDirectory();
     if (!$basedir || !is_dir($basedir)) {
         throw new \RuntimeException("Given basedir '{$basedir}' does not exist or is not a directory");
     }
     $renderer->setBaseDir($basedir);
     $format = $this->config->getDateFormat();
     if ($format) {
         $renderer->setDateTimeFormat($format);
     }
     $renderer->setIndent($this->config->getIndent());
     $renderer->setLineBreak($this->config->getLinebreak());
     foreach ($this->config->getVariables() as $name => $value) {
         $renderer->setVariable($name, $value);
     }
     return $renderer;
 }