处理增量更新

@param string $files
@return void
554759
public function parseIncr($files)
    {
        foreach($files as $file)
        {
            if(isset($this->fileMap[$file]))
            {
                unset($this->fileMap[$file]);
            }
            if(!is_file($file))
            {
                continue;
            }
            $content = file_get_contents($file);
            if(preg_match('/namespace ([^;]+);/', $content, $matches) <= 0)
            {
                continue;
            }
            $namespace = trim($matches[1]);
            $className = $namespace . '\\' . basename($file, '.php');
            if(class_exists($className))
            {
                $this->parse($className);
            }
        }
    }
62233
public function mkFile($files)
    {
        foreach ($files as $file) {
            if (!is_file($file)) {
                @mkdir(dirname($file), 0777, true);
                file_put_contents($file, "<?php\n\nreturn [];\n");
            }
        }
    }
734121
public function setFiles($files = array())
    {
        if (count($files) === 0) {
            $this->_files = $_FILES;
        } else {
            $this->_files = $files;
        }

        foreach($this->_files as $file => $content) {
            if (!isset($content['error'])) {
                unset($this->_files[$file]);
            }
        }

        return $this;
    }
271622
public function addFiles(array $files)
    {
        $added_files = 0;
        try {
            foreach ($files as $localName => $filename) {
                if (!is_null($filename)) {
                    $this->sevenZip->addEntry($filename);
                    $this->sevenZip->renameEntry($filename, $localName);
                    $added_files++;
                }
            }
        } catch (Exception $e) {
            throw new Exception('Could not modify archive: '.$e->getMessage(), $e->getCode(), $e);
        }
        return $added_files;
    }
362379
protected function cleanup(array $files = array())
    {
        if (empty($files)) {
            return $this;
        }
        foreach ($files as $file) {
            if (!file_exists($file->name)) {
                continue;
            }
            unlink($file->name);
        }
        return $this;
    }
297339
public static function incrUpdateRuntime($files)
    {
        $parser = Annotation::getInstance()->getParser();
        $parser->parseIncr($files);

        AnnotationManager::setAnnotations([]);
        AnnotationManager::setAnnotationRelation([]);

        foreach(App::getRuntimeInfo()->parsersData as $parserClass => $data)
        {
            $parserObject = $parserClass::getInstance();
            $parserObject->setData([]);
        }

        foreach($parser->getData() as $className => $item)
        {
            $parser->execParse($className);
        }
    }
226921
public static function run( ? string $files = '*') : bool
    {
        if (self::$status) {
            return false;
        }
        self::$status = 1;
        $config       = Linker::Config()::get('lin')['route'];
        $url          = Linker::Request()::getURL(); //当前url
        $url          = '/' . ltrim($url, '/'); //确保含有根路径
        $method       = Linker::Request()::getMethod(); //当期请求方法

        //url去掉伪后缀名
        foreach ($config['suffix'] as $pattern) {
            $n   = 0;
            $url = preg_replace("/\.$pattern$/", '', $url, 1, $n); //只踢除一次后缀名
            if ($n) {
                break;
            }
        }

        //运行解析器获得执行流程
        if (!$files) {
            $rules = null;
        } else {
            $Parser = new Parser($config);
            $rules  = $Parser->execute($files, $url, strtoupper($method)); //获得执行规则
        }

        //执行通用规则
        if (!$rules) {
            if (is_callable($config['general'])) {
                call_user_func_array($config['general'], [$url, $method]);
            }
            if ($config['debug']) {
                (new Debug)->type('general');
            }
            return true;
        }

        //执行用户规则
        $params = $rules['params'];
        $rules  = $rules['rules'];
        //存在动态参数，合并入当期请求的参数里
        if ($params) {
            $old_params = Linker::Request()::getCurrent();
            Linker::Request()::setCurrent(array_merge($old_params, $params));
        }

        //执行流程
        $return = true;
        $times  = [];
        $t      = microtime(true);
        foreach ($rules as $index => $rule) {
            if ($rule[0] instanceof Closure) {
                $r = call_user_func_array($rule[0], $params); //只有闭包才使用动态参数
            } else {
                $r = call_user_func([new $rule[0], $rule[1]]);
            }
            $times[$index] = microtime(true) - $t;
            if (in_array($r, $config['terminal'], true)) {
                $return = false; //遭遇终止符
                break;
            }
        }
        if ($config['debug']) {
            (new Debug)->process($rules, $params, $index, $times); //记录实际执行流程
        }
        return $return;
    }
1179985
public function requireFiles(array $files)
    {
        $path = $this->getPath();
        foreach ($files as $file) {
            $this->laravel['files']->requireOnce($path . '/' . $file . '.php');
        }
    }
82329
function updateSubmission($submission, $files) {
        $this->_flagSubmitted = false;

        if (empty($submission)) {
            $this->_submitValues = array();
        } else {
            foreach ($submission as $key => $s) {
                $type = $this->getCleanType($key, $s);
                $submission[$key] = $this->getCleanedValue($s, $type);
            }
            $this->_submitValues = $submission;
            $this->_flagSubmitted = true;
        }

        if (empty($files)) {
            $this->_submitFiles = array();
        } else {
            $this->_submitFiles = $files;
            $this->_flagSubmitted = true;
        }

        // need to tell all elements that they need to update their value attribute.
         foreach (array_keys($this->_elements) as $key) {
             $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);
         }
    }
1038151
protected function updateDB($files, $update_updated = true) {
        $module = \jacmoe\mdpages\Module::getInstance();
        $repo = $this->getFlywheelRepo();

        $filename_pattern = '/\.md$/';

        $metaParser = new Meta;

        $file_action = '';

        foreach ($files as $file) {
            if (!preg_match($filename_pattern, $file)) {
                continue;
            }

            $file_field = substr($file, strlen(Yii::getAlias('@pages')));

            if(!file_exists($file)) {
                // if the post exists, delete it
                $page = $repo->query()->where('file', '==', $file_field)->execute();
                $result = $page->first();
                if($result != null) {
                    echo "File $result->file exists - deleting ..\n";

                    $this->deleteCachekeys($module, $result->url);

                    $repo->delete($result);
                }
                $file_action = 'deleted';
                $this->stdout($file_field . ' was ' . $file_action . "\n");
                continue;
            }

            $metatags = array();
            $metatags = $metaParser->parse(file_get_contents($file));

            $url = $file_field;
            $url = ltrim($url, '/');
            $raw_url = pathinfo($url);
            $url = $raw_url['filename'];
            if($url == 'README') continue;
            if($raw_url['dirname'] != '.') {
                $url = $raw_url['dirname'] . '/' . $url;
            }

            $values = array();

            foreach($metatags as $key => $value) {
                $values[$key] = $value;
            }
            $values['url'] = $url;
            $values['file'] = $file_field;

            list($contributors, $dates) = $this->committersFromFile(ltrim($values['file'],'/'), $module);

            $updated_date = 0;
            $created_date = 0;
            if(isset($values['datetime'])) {
                // work-around for existing page collections
                // where the dates in the commits does not apply
                $updated_date = $values['datetime'];
                $created_date = $values['datetime'];
            } else {
                if(count($dates) === 1) {
                    $updated_date = $dates[0];
                    $created_date = $dates[0];
                } else {
                    $updated_date = end($dates);
                    $created_date = reset($dates);
                }
            }

            $file_action = 'created';

            // if the post exists, delete it
            $page = $repo->query()->where('file', '==', $values['file'])->execute();
            $result = $page->first();
            if($result != null) {
                $file_action = 'updated';
                $values['created'] = $result->created;
                $values['updated'] = $update_updated ? $updated_date : $result->updated;

                $this->deleteCachekeys($module, $result->url);

                $repo->delete($result);
            }

            if($file_action == 'created') {
                $values['created'] = $created_date;
                $values['updated'] = $created_date;
            }

            if($module->generate_contributor_data) {
                $values['contributors'] = $contributors;
            }

            $page = new Document($values);
            $repo->store($page);

            $this->stdout($file_field . ' was ' . $file_action . "\n");

        }

    }
138177
public function remove($files)
    {
        foreach ($files as $file) {
            try {
                $this->filesystem->delete($file);
            }
            catch (Exception $e) {
                // Ignore not found exceptions
            }
        }
    }
114751
public static function updateFiles(Event $event, $files, array $info)
    {
        // start
        $io = $event->getIO();
        if ($io->askConfirmation('Jumpstart will now update your files with the provided information. Okay? [yes]:' . "\t")) {
            foreach ($files as $file) {
                $file = array_pop($file);
                $io->write("\t" . $file . "\t", false);
                $io->write(static::updateFile($file, $info) ? 'OK' : 'Error');
            }
            if (file_exists('plugin.php')) {
                rename('plugin.php', $info['plugin_slug'] . '.php');
            }
            $io->write('');
        }
    }
658234
public function update()
    {
        $fs = $this->getFilesystem();
        if ($fs->isDirectory($this->getGitDirectory())) {
            $this->runGit('fetch origin --tags');
        } else {
            $this->initialize();
        }
    }
208985
function setFiles($files)
    {
        $this->files = \Poirot\Http\Psr\normalizeFiles($files);
        return $this;
    }
293473
public function loadCss($files)
    {
        $files = is_string($files) ? [$files] : $files;
        $this->head->loadCollections(['css' => $files]);
    }
586677
protected function validateUploads(array $files): void
    {
        foreach ($files as $file) {
            if (null === $file) {
                continue;
            }
            if ($file instanceof UploadedFileInterface) {
                $this->validateUpload($file);
            } else {
                $this->validateUploads($file);
            }
        }
    }
1054408
public function setFile($file)
    {
        if (is_string($file)) {
            $file = new PhingFile($file);
        }
        $this->file = $file;
    }