解析获取某控制器注释参数信息

@param string $controller 控制器名
@param string $action 方法名

@return array
970637
public static function getAnnotationParams($controller, $action)
    {
        $result = [];

        $reflection = new \ReflectionClass($controller);
        $res = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($res as $method) {
            if ($method->name == $action) {
                $annotation = $method->getDocComment();
                if (strpos($annotation, '@doc') !== false) {
                    //$result[$version][$model]['all'] = $annotation;
                    //描述
                    preg_match('/@desc([^\n]+)/', $annotation, $desc);
                    $result['desc'] = isset($desc[1]) ? trim($desc[1]) : '';
                    //参数
                    preg_match_all('/@param([^\n]+)/', $annotation, $params);
                    foreach ($params[1] as $key => $val) {
                        $tmp = explode(' ', preg_replace('/\s(\s+)/', ' ', trim($val)));
                        isset($tmp[3]) || $tmp[3] = 'N';
                        substr($tmp[1], 0, 1) == '$' && $tmp[1] = substr($tmp[1], 1);
                        $result['params'][] = $tmp;
                    }

                    //请求示例
                    preg_match('/@req(.+?)(\*\s*?@|\*\/)/s', $annotation, $reqEg);
                    $result['req'] = isset($reqEg[1]) ? self::formatCode($reqEg[1]) : '';

                    //请求成功示例
                    preg_match('/@success(.+?)(\*\s*?@|\*\/)/s', $annotation, $success);
                    $result['success'] = isset($success[1]) ? self::formatCode($success[1]) : '';

                    //请求失败示例
                    preg_match('/@error(.+?)(\*\s*?@|\*\/)/s', $annotation, $error);
                    $result['error'] = isset($error[1]) ? self::formatCode($error[1]) : '';
                }
            }
        }
        return $result;
    }
930828
def get_action_params(controller, action)
      comment_lines = get_action_comments(controller, action)

      comments_raw = []
      has_param = false
      comment_lines.each do |line|
        if line.match(/\s*#\s*@param/) # @param id required Integer blah blah
          has_param = true
          comments_raw << ''
        end
        if has_param
          line = line.gsub(/\A\s*#\s*@param/, '')
          line = line.gsub(/\A\s*#\s*/, '').strip

          comments_raw.last << "\n" unless comments_raw.last.blank?
          comments_raw.last << line
        end
      end

      comments = []
      comments_raw.each do |comment|
        match_data = comment.match(/(?<name>[a-z0-9A-Z_\[\]]+)?\s*(?<required>#{PARAM_IMPORTANCES.join('|')})?\s*(?<type>#{PARAM_TYPES.join('|')})?\s*(?<description>.*)/m)

        if match_data
          comments << {
            name: match_data[:name],
            required: match_data[:required],
            type: match_data[:type],
            description: match_data[:description]
          }
        else
          comments << { description: comment }
        end
      end

      comments
    end
59285
protected function convertToControllerAction($action)
    {
        if (is_string($action)) {
            $action = ['uses' => $action];
        }
        
        // Here we'll merge any group "uses" statement if necessary so that the action
        // has the proper clause for this property. Then we can simply set the name
        // of the controller on the action and return the action array for usage.
        if (! empty($this->groupStack)) {
            $action['uses'] = $this->prependGroupUses($action['uses']);
        }
        
        // Here we will set this controller name on the action array just so we always
        // have a copy of it for reference if we need it. This can be used while we
        // search for a controller name or do some other type of fetch operation.
        $action['controller'] = $action['uses'];
        
        return $action;
    }
1267718
protected function parseController($controller)
    {
        if (\is_string($controller) && false !== strpos($controller, '::')) {
            $controller = explode('::', $controller);
        }

        if (\is_array($controller)) {
            try {
                $r = new \ReflectionMethod($controller[0], $controller[1]);

                return [
                    'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
                    'method' => $controller[1],
                    'file' => $r->getFileName(),
                    'line' => $r->getStartLine(),
                ];
            } catch (\ReflectionException $e) {
                if (\is_callable($controller)) {
                    // using __call or  __callStatic
                    return [
                        'class' => \is_object($controller[0]) ? \get_class($controller[0]) : $controller[0],
                        'method' => $controller[1],
                        'file' => 'n/a',
                        'line' => 'n/a',
                    ];
                }
            }
        }

        if ($controller instanceof \Closure) {
            $r = new \ReflectionFunction($controller);

            $controller = [
                'class' => $r->getName(),
                'method' => null,
                'file' => $r->getFileName(),
                'line' => $r->getStartLine(),
            ];

            if (false !== strpos($r->name, '{closure}')) {
                return $controller;
            }
            $controller['method'] = $r->name;

            if ($class = $r->getClosureScopeClass()) {
                $controller['class'] = $class->name;
            } else {
                return $r->name;
            }

            return $controller;
        }

        if (\is_object($controller)) {
            $r = new \ReflectionClass($controller);

            return [
                'class' => $r->getName(),
                'method' => null,
                'file' => $r->getFileName(),
                'line' => $r->getStartLine(),
            ];
        }

        return \is_string($controller) ? $controller : 'n/a';
    }
738516
protected function actionReferencesController($action)
    {
        if ($action instanceof Closure) {
            return false;
        }

        return is_string($action) || is_string(array_get($action, 'uses'));
    }
1245877
protected function parseAction($action)
    {
        if ($action === $this->fullController) {
            return $this->action = null;
        }

        $this->action = strtolower(
            preg_replace(['/^get/', '/^post/', '/^put/', '/^patch/', '/^delete/'], '', $action)
        );
    }
549219
private function detectClassAndMethod(string $controller): ?array
    {
        if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
        } elseif (class_exists($controller)) {
            $class = $controller;
            $method = '__invoke';
        } else {
            if (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
                $controller = $matches[1];
                $method = $matches[2];
            }

            if ($this->container->has($controller)) {
                $class = get_class($this->container->get($controller));

                if (!isset($method) && method_exists($class, '__invoke')) {
                    $method = '__invoke';
                }
            }
        }

        if (!isset($class) || !isset($method)) {
            return null;
        }

        return [$class, $method];
    }
369187
public static function href($controller = null, string $action = null, array $params = null): string
    {
        return Application::route()->href($controller, $action, $params);
    }
576608
public function getActionLink($controller, $action = 'index', $remove = false)
    {
        $key = $this->_getKey($controller, $action);

        if ($this->offsetExists($key)) {

            $result = $this->toActionLink($key);

            if ($remove) {
                $this->offsetUnset($key);
            }

            return $result;
        }
    }
206020
public function getResourceName($controller, $action = null)
    {
        if (isset($action)) {
            return sprintf('controller/%s:%s', $controller, strtolower($action));
        }

        return sprintf('controller/%s', $controller);
    }
83834
public function hasResourceParams($controller, $action = null)
    {
        $this->buildAcl();
        $resource = $this->buildResource($controller, $action);
        return parent::hasResource($resource);
    }
1304640
protected function findControllerAndMethod(array $action)
    {
        if (isset($action['_controller']) || $action['uses']) {
            $controller = isset($action['_controller']) ? $action['_controller'] : $action['uses'];

            if (strstr($controller, ':')) {
                list($controller, $method) = explode(':', $controller);
            } elseif ($action['_method']) {
                $method = $action['_method'];
            }


            $namespace = $this->findNamespaceInController($controller);

            return [$controller, $method, $namespace];

        } else {
            throw new ControllerException('Your controller variable could not found in your route');
        }
    }
922080
protected function convertToControllerAction($action)
    {
        if (is_string($action)) {
            $action = ['uses' => $action];
        }

        // Here we'll merge any group "uses" statement if necessary so that the action
        // has the proper clause for this property. Then we can simply set the name
        // of the controller on the action and return the action array for usage.
        if (! empty($this->groupStack)) {
            $action['uses'] = $this->prependGroupNamespace($action['uses']);
        }

        // Here we will set this controller name on the action array just so we always
        // have a copy of it for reference if we need it. This can be used while we
        // search for a controller name or do some other type of fetch operation.
        $action['controller'] = $action['uses'];

        return $action;
    }
300949
public function action(string $action, string $controller)
    {
        $this->options['actions'][strtolower($action)] = $controller;

        return $this;
    }
1198723
public function getSkipActions(string $controller): array
    {
        return !empty($this->skipActions[$controller]) ? $this->skipActions[$controller] : [];
    }
814998
public static function get_cron($controller,$action){
        $cron = self::find()->where(['controller'=>$controller,'action'=>$action, 'success' => 0])->orderBy('id_cron_job DESC')->one();
        if (is_null($cron)){
            $cron = new CronJob();
            $cron->controller = $controller;
            $cron->action = $action;
        }
        return $cron;
    }
337712
public function Link($action = null) {
		$link = $this->data()->Link(($action ? $action : true));
		
		$params = array();
		
		$tags = $this->getRequest()->getVar('tags');
		if (strlen($tags)) {
			$params['tags'] = $tags;
		}

		$popup = $this->getRequest()->getVar('popup');
		if ($popup) {
			$params['popup'] = 1;
		}
		
		$tagstr = count($params) ? '?' . http_build_query($params) : '';
		return Controller::join_links($link, $tagstr);
	}