获取匹配分组的字符串
@param  $temp
@param  $start
@param  $i
@return array
558154
private function getSlicePattern($temp, $start, $i)
    {
        $regexp = '[^/]+';
        $name = $temp;
        if (strpos($temp, '@') !== false) {
            list($name, $regexpKey) = explode('@', $temp);
            $regexp = $this->getRegexp($regexpKey);
        }
        return [$temp, "(?<" . $name . ">" . $regexp . ")", $start, $i];
    }
474052
private function getReferersCountFromSessionActivities($start, $end)
    {
        return $this->getVisitsFilteredByDateRange($start, $end)
            ->transform(function (VisitorActivity $visit) {
                return [
                    'name' => $visit->hasReferer()
                        ? $visit->referer->domain->name
                        : trans('tracker::generals.undefined'),
                ];
            })
            ->groupBy('name')
            ->transform(function (Collection $items, $key) {
                return [
                    'name'  => $key,
                    'count' => $items->count(),
                ];
            })
            ->sortByDesc('count');
    }
519887
public function sendTemplateVoice($to, $tempId, array $tempData)
    {
        $params = [
            'called_num'        => $to,
            'called_show_num'   => $this->calledShowNum,
            'method'            => 'alibaba.aliqin.fc.tts.num.singlecall',
            'tts_code'          => $tempId,
            'tts_param'         => $this->getTempDataString($tempData),
        ];
        $this->request($params);
    }
961935
static function get_string_between($string, $start, $end){
        try {
            $string = " ".$string;
            $ini = strpos($string,$start);
            if ($ini == 0) return "Start non trouve";
            $ini += strlen($start);
            $len = strpos($string,$end,$ini) - $ini;
            return substr($string,$ini,$len);
        } catch (Exception $e) {
            $msg = $e->getMessage();
            Throw new \Exception('Erreur dans '.__CLASS__.' : '.$msg);
            return null;
        }
    }
931503
public static function find_rules($text, $begin, $end)
	{
		$rules = array();

		$temp = $text;
		$pieces = explode($begin, $temp);
		while(count($pieces) > 1){
			$pieces = explode($end, $pieces[1]);

			$rule = $begin . $pieces[0] . $end;
			array_push($rules, $rule);

			if( count($pieces) == 1 )
				break;

			$temp = str_replace($rule, '', $temp);
			$pieces = explode($begin, $temp);
		}

		return $rules;
	}
482231
public static function buildRequestPreStr($para_temp, $isNew=false)
    {
        //除去待签名参数数组中的空值和签名参数
        $para_filter = self::paraFilter($para_temp, $isNew);

        //对待签名参数数组排序
        $para_sort = self::argSort($para_filter);

        //把数组所有元素，按照“参数=参数值”的模式用“&”字符拼接成字符串
        $prestr = self::createLinkstring($para_sort);

        return $prestr;
    }
1176024
public function getLevels(int $from = 1, ?int $to = null, ?callable $callback = null): array
    {
        $parts = explode('.', $this->env);
        $n = isset($to) ? min(count($parts), $to) : count($parts);

        $levels = [];

        for ($i = $from; $i <= $n; $i++) {
            $level = join('.', array_slice($parts, 0, $i));
            $levels[] = isset($callback) ? $callback($level) : $level;
        }

        return $levels;
    }
325101
public function readGroups(string $before, string $start, string $end, string $after)
    {
        // init
        $groups = [];
        $group = [];
        $position = 'before_search';

        foreach ($this->parsedfile as $edi_row) {
            // search before group segment
            if ($position == 'before_search' && $edi_row[0] == $before) {
                $position = 'before_is';
                continue;
            }

            if ($position == 'before_search') {
                continue;
            }

            if ($position == 'before_is' && $edi_row[0] == $before) {
                continue;
            }

            // after before search start
            if ($position == 'before_is' && $edi_row[0] == $start) {
                $position = 'group_is';
                $group[] = $edi_row;
                continue;
            }

            // if after before segment no start segment, search again before segment
            if ($position == 'before_is') {
                $position = 'before_search';
                continue;
            }

            // get group element
            if ($position == 'group_is' && $edi_row[0] != $end) {
                $group[] = $edi_row;
                continue;
            }

            // found end of group
            if ($position == 'group_is' && $edi_row[0] == $end) {
                $position = 'group_finish';
                $group[] = $edi_row;
                $groups[] = $group;
                $group = [];
                continue;
            }

            // next group start
            if ($position == 'group_finish' && $edi_row[0] == $start) {
                $group[] = $edi_row;
                $position = 'group_is';
                continue;
            }

            // finish
            if ($position == 'group_finish' && $edi_row[0] == $after) {
                break;
            }

            $this->errors[] = 'Reading group ' . $before . '/' . $start . '/' . $end . '/' . $after
                              . '. Error on position: ' . $position;

            return false;
        }

        return $groups;
    }
1081399
public function pagination($start = 1, $length = 10)
	{
		// manually create paginator
		$data = array_map(function ($num) {
			return ['id' => $num, 'value' => "Item $num"];
		}, range(1, 100));
		$page = Paginator::resolveCurrentPage('page');
		$path = Paginator::resolveCurrentPath();
		$items = array_slice($data, abs($start - 1) + (($page - 1) * $length), $length);
		$paginator = new LengthAwarePaginator($items, count($data), $length, $page, [
			'path'     => $path,
			'pageName' => 'page',
		]);

		// append existing parameters
		$paginator->appends(Sketchpad::$params);

		// output
		return view('sketchpad::help/output/pagination', compact('items', 'paginator'));

	}
851035
public function slice( int$start=0, int...$lengths ):string
	{
		return substr($this->getContent(),$start,...array_slice($lengths,0,1));
	}
994288
public function display($tempFile=null) {

		//如果没有传入模板文件，则访问默认模块下的默认模板
        if ( !$tempFile ) {
            $tempFile = $this->configs['action'].'_'.$this->configs['method'].EXT_TPL;
        } else {
            $tempFile .= EXT_TPL;
        }

        //判断是否是引用其他模块的模板, {module}:index.html
        if ( ($idx = strpos($tempFile, ":")) !== false ) {
            $module = substr($tempFile, 0, $idx);
            $this->templateDir = str_replace("/modules/{$this->configs['module']}/", "/modules/{$module}/", $this->templateDir);
            $tempFile = substr($tempFile, $idx+1);
        }
        $compileFile = $tempFile.'.php';
		if ( file_exists($this->templateDir.$tempFile) ) {
            $this->complieTemplate($this->templateDir.$tempFile, $this->compileDir.$compileFile);
			extract($this->templateVar);	//分配变量
			include $this->compileDir.$compileFile;		//包含编译生成的文件
		} else {
			if ( APP_DEBUG ) {
                E("要编译的模板[".$this->templateDir.$tempFile."] 不存在！");
            }
		}

	}
964419
public function slice($start=0, $end=-1) {
        if ( $end == -1 ) return substr($this->internal, $start);
        $len = $end - $start - 1;
        return substr($this->internal, $start, $len);
    }
1294941
public static function method($method, $base_class = null, $model = false, $constructor_parameters = null) {
		$temp = explode('::', $method);
		if (count($temp) > 1) {
			$temp_model = $temp[0];
			$temp_method = $temp[1];
		} else {
			$temp_model = $base_class;
			$temp_method = $temp[0];
		}
		if ($model) {
			$temp_model = \Factory::model($temp_model, false, $constructor_parameters);
		}
		return [& $temp_model, $temp_method];
	}
1089093
public static function getStartEndMonth() : array
    {
        date_default_timezone_set('UTC');
        $begin = mktime(0, 0, 0, date('m'), 1, date("Y"));
        $end = mktime(23, 59, 59, date('m'), date("t"), date("Y"));
        return [
            'begin' => $begin,
            'end' => $end
        ];
    }
1255353
public function sendTemplateSms($to, $tempId, array $tempData)
    {
        $params = [
            'method'             => 'alibaba.aliqin.fc.sms.num.send',
            'sms_type'           => 'normal',
            'sms_free_sign_name' => $this->smsFreeSignName,
            'sms_param'          => $this->getTempDataString($tempData),
            'rec_num'            => $to,
            'sms_template_code'  => $tempId,
        ];
        $this->request($params);
    }
759354
public function get_entries($start=0, $limit=10) {
        global $DB;

        if ($this->entries === null) {
            if ($sqlarray = $this->get_entry_fetch_sql(false, 'created DESC')) {
                $this->entries = $DB->get_records_sql($sqlarray['sql'], $sqlarray['params'], $start, $limit);
                if (!$start && count($this->entries) < $limit) {
                    $this->totalentries = count($this->entries);
                }
            } else {
                return false;
            }
        }

        return $this->entries;
    }
309125
public function getItems($count = null, $start = 0)
    {
        $matches = $this->gateway->getAll($this->table);
        $matches = $this->applyConditions($matches);
        $matches = $this->applyOrdering($matches);

        if (!empty($this->columns)) {
            $result = $this->applyColumns($matches);
        } else {
            $result = $this->castToEntity($matches);
        }

        return array_slice($result, $start, $count);
    }