开始执行分析
@parem bool optimize 是否对结果进行优化
@return bool
496273
public function StartAnalysis($optimize=true)
    {
        if( !$this->isLoadDic )
        {
            $this->LoadDict();
        }
        $this->simpleResult = $this->finallyResult = array();
        $this->sourceString .= chr(0).chr(32);
        $slen = strlen($this->sourceString);
        $sbcArr = array();
        $j = 0;
        //全角与半角字符对照表
        for($i=0xFF00; $i < 0xFF5F; $i++)
        {
            $scb = 0x20 + $j;
            $j++;
            $sbcArr[$i] = $scb;
        }
        //对字符串进行粗分
        $onstr = '';
        $lastc = 1; //1 中/韩/日文, 2 英文/数字/符号('.', '@', '#', '+'), 3 ANSI符号 4 纯数字 5 非ANSI符号或不支持字符
        $s = 0;
        $ansiWordMatch = "[0-9a-z@#%\+\.-]";
        $notNumberMatch = "[a-z@#%\+]";
        for($i=0; $i < $slen; $i++)
        {
            $c = $this->sourceString[$i].$this->sourceString[++$i];
            $cn = hexdec(bin2hex($c));
            $cn = isset($sbcArr[$cn]) ? $sbcArr[$cn] : $cn;
            //ANSI字符
            if($cn < 0x80)
            {
                if( preg_match('/'.$ansiWordMatch.'/i', chr($cn)) )
                {
                    if( $lastc != 2 && $onstr != '') {
                        $this->simpleResult[$s]['w'] = $onstr;
                        $this->simpleResult[$s]['t'] = $lastc;
                        $this->_deep_analysis($onstr, $lastc, $s, $optimize);
                        $s++;
                        $onstr = '';
                    }
                    $lastc = 2;
                    $onstr .= chr(0).chr($cn);
                }
                else
                {
                    if( $onstr != '' )
                    {
                        $this->simpleResult[$s]['w'] = $onstr;
                        if( $lastc==2 )
                        {
                            if( !preg_match('/'.$notNumberMatch.'/i', iconv(UCS2, 'utf-8', $onstr)) ) $lastc = 4;
                        }
                        $this->simpleResult[$s]['t'] = $lastc;
                        if( $lastc != 4 ) $this->_deep_analysis($onstr, $lastc, $s, $optimize);
                        $s++;
                    }
                    $onstr = '';
                    $lastc = 3;
                    if($cn < 31)
                    {
                        continue;
                    }
                    else
                    {
                        $this->simpleResult[$s]['w'] = chr(0).chr($cn);
                        $this->simpleResult[$s]['t'] = 3;
                        $s++;
                    }
                }
            }
            //普通字符
            else
            {
                //正常文字
                if( ($cn>0x3FFF && $cn < 0x9FA6) || ($cn>0xF8FF && $cn < 0xFA2D)
                    || ($cn>0xABFF && $cn < 0xD7A4) || ($cn>0x3040 && $cn < 0x312B) )
                {
                    if( $lastc != 1 && $onstr != '')
                    {
                        $this->simpleResult[$s]['w'] = $onstr;
                        if( $lastc==2 )
                        {
                            if( !preg_match('/'.$notNumberMatch.'/i', iconv(UCS2, 'utf-8', $onstr)) ) $lastc = 4;
                        }
                        $this->simpleResult[$s]['t'] = $lastc;
                        if( $lastc != 4 ) $this->_deep_analysis($onstr, $lastc, $s, $optimize);
                        $s++;
                        $onstr = '';
                    }
                    $lastc = 1;
                    $onstr .= $c;
                }
                //特殊符号
                else
                {
                    if( $onstr != '' )
                    {
                        $this->simpleResult[$s]['w'] = $onstr;
                        if( $lastc==2 )
                        {
                            if( !preg_match('/'.$notNumberMatch.'/i', iconv(UCS2, 'utf-8', $onstr)) ) $lastc = 4;
                        }
                        $this->simpleResult[$s]['t'] = $lastc;
                        if( $lastc != 4 ) $this->_deep_analysis($onstr, $lastc, $s, $optimize);
                        $s++;
                    }
                    
                    //检测书名
                    if( $cn == 0x300A )
                    {
                        $tmpw = '';
                        $n = 1;
                        $isok = false;
                        $ew = chr(0x30).chr(0x0B);
                        while(true)
                        {
                            if( !isset($this->sourceString[$i+$n+1]) )  break;
                            $w = $this->sourceString[$i+$n].$this->sourceString[$i+$n+1];
                            if( $w == $ew )
                            {
                                $this->simpleResult[$s]['w'] = $c;
                                $this->simpleResult[$s]['t'] = 5;
                                $s++;
                        
                                $this->simpleResult[$s]['w'] = $tmpw;
                                $this->newWords[$tmpw] = 1;
                                if( !isset($this->newWords[$tmpw]) )
                                {
                                    $this->foundWordStr .= $this->_out_string_encoding($tmpw).'/nb, ';
                                    $this->SetWordInfos($tmpw, array('c'=>1, 'm'=>'nb'));
                                }
                                $this->simpleResult[$s]['t'] = 13;
                                
                                $s++;

                                //最大切分模式对书名继续分词
                                if( $this->differMax )
                                {
                                    $this->simpleResult[$s]['w'] = $tmpw;
                                    $this->simpleResult[$s]['t'] = 21;
                                    $this->_deep_analysis($tmpw, $lastc, $s, $optimize);
                                    $s++;
                                }
                                
                                $this->simpleResult[$s]['w'] = $ew;
                                $this->simpleResult[$s]['t'] =  5;
                                $s++;
                        
                                $i = $i + $n + 1;
                                $isok = true;
                                $onstr = '';
                                $lastc = 5;
                                break;
                            }
                            else
                            {
                                $n = $n+2;
                                $tmpw .= $w;
                                if( strlen($tmpw) > 60 )
                                {
                                    break;
                                }
                            }
                        }//while
                        if( !$isok )
                        {
                            $this->simpleResult[$s]['w'] = $c;
                              $this->simpleResult[$s]['t'] = 5;
                              $s++;
                              $onstr = '';
                            $lastc = 5;
                        }
                        continue;
                    }
                    
                    $onstr = '';
                    $lastc = 5;
                    if( $cn==0x3000 )
                    {
                        continue;
                    }
                    else
                    {
                        $this->simpleResult[$s]['w'] = $c;
                        $this->simpleResult[$s]['t'] = 5;
                        $s++;
                    }
                }//2byte symbol
                
            }//end 2byte char
        
        }//end for
        
        //处理分词后的结果
        $this->_sort_finally_result();
    }
1134468
protected function doExecute()
    {
        $paths = $this->getArgument(0);

        $paths = Arr::toArray($paths);

        if ($paths === []) {
            $p = $this->getOption('p');

            $dir = ConsoleHelper::getAllPackagesResolver()->getPackage($p)->getDir();

            $paths = [
                $dir . '/routing.yml',
                $dir . '/Resources/routing/**/*.yml'
            ];
        }

        $files = [];

        foreach ($paths as $path) {
            $files[] = \Windwalker\glob($path);
        }

        $files = array_merge(...$files);

        foreach ($files as $file) {
            $this->convert($file);
        }

        return true;
    }
943724
public function actionOptimize()
    {
        $this->stdout("Optimizing translations...\n", Console::BOLD);
        $optimizer = new Optimizer();
        $items = $optimizer->run();
        $this->stdout("{$items} removed from database.\n");
    }
1288698
public function optimize($core = null)
    {
        if ($core === null) {
            $core = $this->getCore();
        }

        return $this->request('GET', $core.'/update', ['optimize' => 'true']);
    }
321061
public function run()
    {
        if ($this->help) {

            return $this->showHelp();
        }
        if ($this->confFile) {
            $fakerino = Fakerino::create($this->confFile);
        } else {
            $fakerino = Fakerino::create();
            if ($this->locale) {
                $conf = array();
                $conf['locale'] = $this->locale;
                $fakerino = Fakerino::create($conf);
            }
        }
        if (!$this->num) {
            $this->num = 1;
        }
        if ($this->table) {
            $fakerino->num($this->num)->fakeTable($this->table);

            return;
        }
        if ($this->templateSource) {
            return $fakerino->num($this->num)->fakeTemplate($this->templateSource) . PHP_EOL;
        }
        $fakerino = $fakerino->fake($this->input)->num($this->num);

        if ($this->json) {
            $result = $fakerino->toJson();
        } else {
            $result = (string)$fakerino;
        }

        return $result . PHP_EOL;
    }
1237705
public function min() {
		if ($this->output !== '') { // min already run
			return $this->output;
		}

		$mbIntEnc = null;
		if (function_exists('mb_strlen') && ((int)ini_get('mbstring.func_overload') & 2)) {
			$mbIntEnc = mb_internal_encoding();
			mb_internal_encoding('8bit');
		}
		$this->input = str_replace("\r\n", "\n", $this->input);
		$this->inputLength = strlen($this->input);

		$this->action(self::ACTION_DELETE_A_B);

		while ($this->a !== null) {
			// determine next command
			$command = self::ACTION_KEEP_A; // default
			if ($this->a === ' ') {
				if (($this->lastByteOut === '+' || $this->lastByteOut === '-')
				    && ($this->b === $this->lastByteOut)
				) {
					// Don't delete this space. If we do, the addition/subtraction
					// could be parsed as a post-increment
				} elseif (!$this->isAlphaNum($this->b)) {
					$command = self::ACTION_DELETE_A;
				}
			} elseif ($this->a === "\n") {
				if ($this->b === ' ') {
					$command = self::ACTION_DELETE_A_B;
					// in case of mbstring.func_overload & 2, must check for null b,
					// otherwise mb_strpos will give WARNING
				} elseif ($this->b === null
				          || (false === strpos('{[(+-', $this->b)
				              && !$this->isAlphaNum($this->b))
				) {
					$command = self::ACTION_DELETE_A;
				}
			} elseif (!$this->isAlphaNum($this->a)) {
				if ($this->b === ' '
				    || ($this->b === "\n"
				        && (false === strpos('}])+-"\'', $this->a)))
				) {
					$command = self::ACTION_DELETE_A_B;
				}
			}
			$this->action($command);
		}
		$this->output = trim($this->output);

		if ($mbIntEnc !== null) {
			mb_internal_encoding($mbIntEnc);
		}
		return $this->output;
	}
933450
protected function isLastLoop(): bool
    {
        // Count loop
        if (!is_null($this->getLoopMax()) && ($this->getLoopCount() >= $this->getLoopMax())) {
            $this->requestShutdown();
        }

       // Memory
        if ($this->memoryMax > 0 && memory_get_peak_usage(true) >= $this->memoryMax) {
            $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_MAX_MEMORY_REACHED);
            $this->requestShutdown();
        }

        return $this->isShutdownRequested();
    }
194022
public function run()
    {
        if (! $this->runPreSearch()) {
            return $this->value;
        }

        $matches = [];
        if (preg_match_all('/(?:(?:\A|[^\d])0x[a-f\d]{3,}[a-f\d]*)+/im', $this->value, $matches)) {
            foreach ($matches[0] as $match) {
                $converted = '';
                foreach (str_split($match, 2) as $hexIndex) {
                    if (preg_match('/[a-f\d]{2,3}/i', $hexIndex)) {
                        $converted .= chr(hexdec($hexIndex));
                    }
                }
                $this->value = str_replace($match, $converted, $this->value);
            }
        }
        // take care of hex encoded ctrl chars
        $this->value = preg_replace('/0x\d+/m', ' 1 ', $this->value);

        return $this->value;
    }
1026852
private function optimizeDirs()
    {
        $this->optimizedDirs = [];
        foreach ($this->dirs as $pathname) {
            $pathname = \BearFramework\Internal\Utilities::normalizePath($pathname);
            if (substr($pathname, -3) !== '://') {
                $pathname = rtrim($pathname, '/') . '/';
            }
            $this->optimizedDirs[$pathname] = strlen($pathname);
        }
        arsort($this->optimizedDirs);
        $this->optimizedDirs = array_keys($this->optimizedDirs);
    }
260029
public function min()
    {
        if ($this->output !== '') { // min already run
            return $this->output;
        }
        $this->action(self::ACTION_DELETE_A_B);
        
        while ($this->a !== null) {
            // determine next command
            $command = self::ACTION_KEEP_A; // default
            if ($this->a === ' ') {
                if (! $this->isAlphaNum($this->b)) {
                    $command = self::ACTION_DELETE_A;
                }
            } elseif ($this->a === "\n") {
                if ($this->b === ' ') {
                    $command = self::ACTION_DELETE_A_B;
                } elseif (false === strpos('{[(+-', $this->b) 
                          && ! $this->isAlphaNum($this->b)) {
                    $command = self::ACTION_DELETE_A;
                }
            } elseif (! $this->isAlphaNum($this->a)) {
                if ($this->b === ' '
                    || ($this->b === "\n" 
                        && (false === strpos('}])+-"\'', $this->a)))) {
                    $command = self::ACTION_DELETE_A_B;
                }
            }
            $this->action($command);
        }
        $this->output = trim($this->output);
        return $this->output;
    }
1148375
public function run()
    {
        if (!$this->isRan) {
            $this->isRan = true;
            foreach ($this->items as $aItem) {
                $mOpt      = isset($aItem[2]) ? $aItem[2] : array();
                $sRuleName = $aItem[1];
                foreach (is_array($aItem[0]) ? $aItem[0] : array($aItem[0]) as $sFieldName) {
                    self::applyRuleToField($sFieldName, $sRuleName, $mOpt);
                }
            }
        }
        return $this;
    }
201740
public function optimize($path)
    {
        $optim = new PHPImageOptim();
        $optim->setImage($path);

        $type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);
        switch ($type) {
            case self::TYPE_JPEG:
                $optim->chainCommand($this->jpegOptim);
                break;
            case self::TYPE_PNG:
                $optim->chainCommand($this->optiPng);
                break;
            case self::TYPE_GIF:
                 //$optim->chainCommand($this->gifsicle);
                 return false;
                break;
            default:
                return false;
        }

        return $optim->optimise();
    }
867004
static function optimizeFunction( $useComments, &$php, $tpl, &$node, &$resourceData )
    {
        $ret = 0;
        /* Just run the optimizer over all parameters */
        if ( isset( $node[3] ) and is_array( $node[3] ) )
        {
            foreach ( $node[3] as $key => $parameter )
            {
                $ret = $ret | eZTemplateOptimizer::optimizeVariable( $useComments, $php, $tpl, $node[3][$key], $resourceData );
            }
        }
        return $ret;
    }
749281
protected function optimizeApplication()
    {
        $this->call('config:clear');
        $this->call('route:clear');
        $this->call('clear-compiled');

        if ($this->laravel->environment('production') && !$this->option('no-cache')) {
            $this->call('config:cache');
            $this->call('route:cache');
        }

        if (!$this->option('no-optimize')) {
            $this->call('antares:optimize');
        }
    }
919318
private function regular() {
        /** 获取PATHINFO */
        $pathInfo = $this->pathInfo;//$this->getPathInfo();
        foreach ($this->routingTable as $key => $route) {
            if (!preg_match($route['regx'], $pathInfo, $matches)) {
                continue;
            }
            $this->current = $key;
            /** 载入参数 */
            $params = NULL;
            if (!empty($route['params'])) {
                unset($matches[0]);
                $params = array_combine($route['params'], $matches);
                $req = Request::driver();
                $req->get = array_merge($req->get,$params);
                $req->request = array_merge($req->request,$params);
            }
            $this->pathInfo = '/'.$route['action'];
            return true;
        }
        return false;
    }
195618
public function run()
	{
		if( isset( $this->config['task_list'] ) && !empty( $this->config['task_list'] ) ){
			$task_list            = $this->config['task_list'];
			$cronLastExecTimeList = [];
			// 定时执行
			ServerManager::getInstance()->getServer()->tick( $this->config['loop_time'] * 1000, function() use ( &$task_list, &$cronLastExecTimeList ){
				// 分别执行
				foreach( $task_list as $name => $option ){
					try{
						// 是到期需执行 当前时间 > 最后一次时间 + 间隔时间
						$last_time     = isset( $cronLastExecTimeList[$name] ) ? $cronLastExecTimeList[$name] : 0;
						$current_time  = time();
						$interval_time = ceil( $option['interval_time'] );

						if( $current_time > ($last_time + $interval_time) ){
							// 设置最后一次执行时间 不可等任务执行完毕后再设置时间，因为会阻塞导致每秒进行一次
							$cronLastExecTimeList[$name] = $current_time;
							// 检测是否可执行
							if( \ezswoole\Cron::checkTask( $name, $option ) === true ){
								\EasySwoole\Core\Swoole\Task\TaskManager::async( function() use ( $name, $option ){
									\ezswoole\Cron::exec( $name, $option );
									return true;
								} );
							} else{
								// 删除该任务
								unset( $task_list[$name] );
							}
						}
					} catch( \Exception $e ){
						\EasySwoole\EasySwoole\Logger::getInstance()->log($e->getTraceAsString(),'error');
					}
				}
			} );
		}
		return true;
	}
721484
public function optimize()
	{
		$update = $this->connection->createUpdate();
		$update->addOptimize();
		return $this->connection->update($update);
	}