未提供项目描述
项目描述
pyPhpTree 模块
Python 3 的模块。PHP 源代码的微型解析器,可查找带有类/函数/命名空间/特征声明的行。它只在<? ... ?>标签(一个文件中的任意数量的片段),在/* ... */和// ...注释之外,以及在单/双引号字符串之外(支持多行字符串,支持转义反斜杠),以及在heredoc/herenow 块之外。
API
函数get_headers(filename, lines)在给定的“行”列表中查找所有实体,并获取字典:
{
'line': int, # 0-based line index, where name found
'col': int, # 0-based position in line, where name found
'level': int, # 0-based level of item. each item of level K+1
# is nested into (nearest upper) item of level K
'name': str, # name of entity
# empty for anonymous funcs
'kind': str, # "class", "function", "namespace", "trait"
}
它是生成器(产量),因此要获取列表,请使用list(get_headers(...))。