查找和修改下级代码对象

@param string        $type     代码类型
@param bool/string   $pattern   名称正则式
@param null/function $callback 修改回调函数
@return array
764616
public function find($type, $pattern = false, $callback = null)
    {
        if (!isset($this->{$type})) {
            return [];
        }
        $components = to_array($this->{$type}, false);
        $result = [];
        foreach ($components as $name => $node) {
            if (empty($pattern) || preg_match($pattern, $name)) {
                if (is_callable($callback)) {
                    $node = exec_function_array($callback, [$node, $this]);
                }
                $result[$name] = $node;
            }
        }
        return $result;
    }
903581
public function put(string $pattern, callable $callback)
    {
        if ($this->requestMethod === "PUT") {
            $this->mapRoute($pattern, $callback);
        }
    }
186354
public function getKeys($pattern = null)
    {
        $keys = $this->get('__stored_keys__', []);
        if (is_null($pattern)) {
            return $keys;
        }

        $matches = [];
        $pattern = $this->_normalizePattern($pattern);
        foreach ($keys as $key) {
            if (preg_match($pattern, $key)) {
                $matches[] = $key;
            }
        }

        return $matches;
    }
585051
private function findSourcesInPattern(string $pattern): array
  {
    $sources = [];

    $directory = new RecursiveDirectoryIterator(self::getLeadingDir($pattern));
    $directory->setFlags(RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
    $files = new RecursiveIteratorIterator($directory);
    foreach ($files as $fullPath => $file)
    {
      // If the file is a source file with stored routine add it to my sources.
      if ($file->isFile() && SelectorHelper::matchPath($pattern, $fullPath))
      {
        $sources[] = $fullPath;
      }
    }

    return $sources;
  }
446509
public static function checkCompareRule($rule, $valueCallback)
    {
        if(isset($rule[0]) && '!' === $rule[0])
        {
            // 不应该存在参数支持
            return null === call_user_func($valueCallback, substr($rule, 1));
        }
        else if(preg_match('/([^!<=]+)(!=|<>|=)(.+)/', $rule, $matches) > 0)
        {
            $value = call_user_func($valueCallback, $matches[1]);
            switch($matches[2])
            {
                case '!=':
                case '<>':
                    return null !== $value && $value != $matches[3];
                case '=':
                    return $value == $matches[3];
                default:
                    return false;
            }
        }
        else
        {
            return null !== call_user_func($valueCallback, $rule);
        }
    }
49807
public function backtraceFocus($pattern = null)
    {
        if ($pattern === null) {
            return $this->_backtraceFocus;
        }
        $patterns = is_array($pattern) ? $pattern : [$pattern];
        foreach ($patterns as $key => $value) {
            $patterns[$key] = preg_quote($value, '~');
        }
        $pattern = join('|', $patterns);
        return $this->_backtraceFocus = strtr($pattern, ['\*' => '.*', '\?' => '.']);
    }
759832
public function select(string $pattern): \Iterator
    {
        //游标,每次查询必须从0开始
        $iterator = NULL;
        while (true) {
            //查询并更新游标
            $ret = $this->handle->zScan($this->name, $iterator, $pattern, 10);

            //没有更多数据了
            if (false === $ret) {
                break;
            }

            //逐个返回
            foreach ($ret as $key => $val) {
                yield [$key => $val];
            }
        }
    }
848111
public function on($target, $type, $callback = null)
    {
        if (is_null($callback)) {
            $callback = $type;
            $type     = '*';
        }

        if (!is_callable($callback)) {
            throw new Exception("$callback 不是一个可调用的函数或方法");
        }

        $type = strtolower($type);

        $listeners = $this->listeners->get("{$target}.{$type}") ?: array();

        array_push($listeners, $callback);

        $this->listeners->set("{$target}.{$type}", $listeners);

        return $this;
    }
351064
public function get(string $pattern, callable $callback)
    {
        if ($this->requestMethod === "GET") {
            $this->mapRoute($pattern, $callback);
        }
    }
988360
protected function buildRegExp($pattern)
    {
        $pattern = '/' . trim($pattern, '/');
        $pattern = str_replace('/', '\/', $pattern);
        preg_match_all('#((\\\/)?[^\\\/]+)#im', $pattern, $patternMatches);

        foreach ($patternMatches[1] as &$match) {
            if (strpos($match, '*') !== false) {
                $match = str_replace('*', self::ANY, $match);
            }

            if (preg_match('#\(![^\)]+\)#i', $match)) {
                $match = preg_replace_callback(
                    '/^(.*)\(!([^\)]+)\)$/i',
                    array($this, 'buildRegExpCallback'),
                    $match,
                    \PREG_SET_ORDER
                );
            }

            unset($match);
        }

        $pattern = str_replace($patternMatches[0], $patternMatches[1], $pattern);
        $pattern = '/^' . $pattern . '\/?.*$/i';

        return $pattern;
    }
911333
protected function extractAuthParameters($pattern, $channel, $callback)
    {
        $callbackParameters = (new ReflectionFunction($callback))->getParameters();

        return collect($this->extractChannelKeys($pattern, $channel))->reject(function ($value, $key) {
            return is_numeric($key);
        })->map(function ($value, $key) use ($callbackParameters) {
            return $this->resolveBinding($key, $value, $callbackParameters);
        })->values()->all();
    }
839341
public function getCallbacksByType($type)
    {
        if (array_key_exists($type, $this->callbacks) && count($this->callbacks[$type]) > 0) {
            return $this->callbacks[$type];
        }

        return [];
    }
305544
public function list_tags($pattern = null) {
		$tagArray = explode("\n", $this->run("tag -l $pattern"));
		foreach ($tagArray as $i => &$tag) {
			$tag = trim($tag);
			if ($tag == '') {
				unset($tagArray[$i]);
			}
		}

		return $tagArray;
	}
378968
public function map(array $methods, $pattern, $callable)
    {
        $callable = is_string($callable) ? $this->resolveCallable($callable) : $callable;
        if ($callable instanceof Closure) {
            $callable = $callable->bindTo($this);
        }

        $route = $this->container->get('router')->map($methods, $pattern, $callable);
        if (is_callable([$route, 'setContainer'])) {
            $route->setContainer($this->container);
        }

        if (is_callable([$route, 'setOutputBuffering'])) {
            $route->setOutputBuffering($this->container->get('settings')['outputBuffering']);
        }

        return $route;
    }
159976
public function registerFilter($type, $callback)
    {
        $this->smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback;
    }
200055
function getPattern(type_, limit) {
      if (!type_) return;
      if (isUdf(limit)) limit = true;
      if (contains(['all', 'list'], type_)) return keys(patterns);
      if (!has(patterns, type_)) return UDF;
      var pattern = patterns[type_];
      return limit ? new RegExp('^(' + pattern.source.replace(/^(\^|\$)$/mg, '') + ')$') : pattern;
    }
282140
public function query($method, $pattern, $callback)
    {
        $route = new Route($pattern, $callback, $method);
        $this['router']->addRoute($route);

        return $route;
    }