src/Leevel/Kernel/Utils/Doc.php
protected function parseComment(string $comment): array
    {
        $comments = explode(PHP_EOL, $comment);
        $findApi = false;
        $result = [];
        $code = ['$result = ['];

        foreach ($comments as $v) {
            $v = trim($v, '* ');
            $v = trim($v, '_'); // 删除占位符

            if ('@api(' === $v) {
                $findApi = true;
            } elseif (true === $findApi) {
                if (')' === $v) {
                    break;
                }
                // 匹配字段格式，以便于支持多行
                if (preg_match('/^\S+=\"/', $v)) {
                    $pos = strpos($v, '=');
                    $left = '"'.substr($v, 0, $pos).'"';
                    $right = substr($v, $pos + 1);
                    $right = str_replace('$', '\$', $right); // 转义变量

                    $code[] = $left.'=>'.$right;
                } else {
                    // 空行加两个换行符撑开
                    if ('' === $v) {
                        $code[] = PHP_EOL.PHP_EOL;
                    } else {
                        $code[] = str_replace('$', '\$', $v).PHP_EOL; // 转义变量
                    }
                }
            }
        }

        $code[] = '];';
        eval(implode('', $code));

        return $result;
    }
protected function parseComment(string $comment): array
    {
        $comments = explode(PHP_EOL, $comment);
        $findApi = false;
        $result = [];
        $code = ['$result = ['];

        foreach ($comments as $v) {
            $v = trim($v, '* ');
            $v = trim($v, '_'); // 删除占位符

            if ('@api(' === $v) {
                $findApi = true;
            } elseif (true === $findApi) {
                if (')' === $v) {
                    break;
                }
                // 匹配字段格式，以便于支持多行
                if (preg_match('/^\S+=\"/', $v)) {
                    $pos = strpos($v, '=');
                    $left = '"'.substr($v, 0, $pos).'"';
                    $right = substr($v, $pos + 1);
                    $right = str_replace('$', '\$', $right); // 转义变量

                    $code[] = $left.'=>'.$right;
                } else {
                    // 空行加两个换行符撑开
                    if ('' === $v) {
                        $code[] = PHP_EOL.PHP_EOL;
                    } else {
                        $code[] = str_replace('$', '\$', $v).PHP_EOL; // 转义变量
                    }
                }
            }
        }

        $code[] = '];';
        eval(implode('', $code));

        return $result;
    }
获取 API 注解信息.

@param string $comment

@return array