Exakat\Tasks\Load::processFile PHP Метод

processFile() приватный Метод

private processFile ( $filename )
    private function processFile($filename)
    {
        $this->log->log("{$filename}");
        $this->filename = $filename;
        $this->line = 0;
        $log = array();
        if (is_link($filename)) {
            return true;
        }
        if (!file_exists($filename)) {
            throw new NoSuchFile($filename);
        }
        $file = realpath($filename);
        if (strpos($file, '/code/') !== false) {
            $file = substr($file, strpos($file, '/code/') + 5);
        } else {
            $file = $filename;
        }
        if (filesize($filename) === 0) {
            return false;
        }
        if (!$this->php->compile($filename)) {
            display('Ignoring file ' . $filename . ' as it won\'t compile with the configured PHP version (' . $this->config->phpversion . ')');
            return false;
        }
        $tokens = $this->php->getTokenFromFile($filename);
        $log['token_initial'] = count($tokens);
        if (count($tokens) === 1) {
            display('Ignoring file ' . $filename . ' as it is not a PHP file (No PHP token found)');
            return false;
        }
        $line = 0;
        $this->tokens = array();
        foreach ($tokens as $t) {
            if (is_array($t)) {
                if ($t[0] === T_COMMENT || $t[0] === T_WHITESPACE || $t[0] === T_DOC_COMMENT) {
                    $line += substr_count($t[1], "\n");
                    continue;
                } else {
                    $line = $t[2];
                    $this->tokens[] = $t;
                }
            } else {
                $this->tokens[] = array(0 => self::$TOKENS[$t], 1 => $t, 2 => $line);
            }
        }
        // Final token
        $this->tokens[] = array(0 => T_END, 1 => '/* END */', 2 => $line);
        unset($tokens);
        $id1 = $this->addAtom('File');
        $this->setAtom($id1, array('code' => $filename, 'fullcode' => $file, 'line' => -1, 'token' => 'T_FILENAME'));
        $this->addLink($this->id0, $id1, 'PROJECT');
        $n = count($this->tokens) - 2;
        $this->id = 0;
        // set to 0 so as to calculate line in the next call.
        $this->startSequence();
        // At least, one sequence available
        $this->id = -1;
        do {
            $theId = $this->processNext();
            #            display( "$this->id / $n\n");
            if ($theId > 0) {
                $this->addToSequence($theId);
            }
        } while ($this->id < $n);
        $sequenceId = $this->sequence;
        $this->endSequence();
        $this->addLink($id1, $sequenceId, 'FILE');
        $this->setAtom($sequenceId, array('root' => true));
        $this->checkTokens($filename);
        #        display( count($this->atoms)." atoms\n");
        #        display( count($this->links)." links\n");
        #        display( "Final id : $this->id\n");
        return true;
    }
Load