Exemplo n.º 1
0
 public function __construct($prefix = null)
 {
     parent::__construct();
     if (!empty($prefix)) {
         $this->prefix = $prefix;
     }
 }
Exemplo n.º 2
0
 private function parseFiles(array $files, array $defines = array())
 {
     $this->files_queued = $files;
     $Statements = array();
     $index = 0;
     while (($file = array_shift($this->files_queued)) !== null) {
         $file = realpath($file);
         // @todo Test if this works
         if (in_array($file, $this->files_done)) {
             continue;
         }
         $this->current_file = $file;
         $this->files_done[] = $file;
         ++$index;
         $this->Preprocessor->resetDefines();
         $this->Preprocessor->addDefines($defines);
         $source = $this->Preprocessor->preprocessFile($file);
         $mode = null;
         $namespace = '';
         $tokens = token_get_all($source);
         $token = reset($tokens);
         while ($token) {
             switch ($token[0]) {
                 case T_NAMESPACE:
                     $mode = T_NAMESPACE;
                     break;
                 case T_NS_SEPARATOR:
                 case T_STRING:
                     if ($mode === T_NAMESPACE) {
                         $namespace .= $token[1];
                     }
                     break;
                 case ';':
                     $mode = null;
                     break;
                 case T_CLASS:
                 case T_INTERFACE:
                     $Class = new Entity\ParserClass($this, $tokens, $this->lastStatements);
                     $this->Classes[strtolower($Class->name)] = $Class;
                     $this->lastStatements = null;
                     break;
                 case T_FUNCTION:
                     $Function = new Entity\ParserFunction($this, $tokens, $this->lastStatements);
                     $this->Functions[strtolower($Function->name)] = $Function;
                     $this->lastStatements = null;
                     break;
                 case T_COMMENT:
                     if ($this->lastStatements) {
                         $this->Statements = array_merge($this->Statements, $this->lastStatements);
                         $this->lastStatements = null;
                     }
                     $Statements = $this->tokenToStatements($token);
                     $this->queueClassesFromComments($Statements);
                     $this->Statements = array_merge($this->Statements, $Statements);
                     break;
                 case T_DOC_COMMENT:
                     if ($this->lastStatements) {
                         $this->Statements = array_merge($this->Statements, $this->lastStatements);
                     }
                     $Statements = $this->tokenToStatements($token);
                     $this->queueClassesFromComments($Statements);
                     $this->lastStatements = $Statements;
                     break;
             }
             $token = next($tokens);
         }
         //var_dump($namespace);	//@todo do something with this -> assign to classes and use for queueing, classloader and inheritance (relative/absolute!)
         if ($this->lastStatements) {
             $this->Statements = array_merge($this->Statements, $this->lastStatements);
             $this->lastStatements = null;
         }
     }
     $this->current_file = null;
 }