michaeljoelphillips / ctags-php
读取由 universal ctags 生成的标签文件
0.0.3
2020-11-25 03:55 UTC
Requires
- php: ^7.4
Requires (Dev)
- doctrine/coding-standard: ^8.1
- phpbench/phpbench: ^0.17.1
- phpstan/phpstan: ^0.12.56
- phpunit/phpunit: ^9.4
This package is auto-updated.
Last update: 2024-09-25 13:58:57 UTC
README
此库提供对各种版本的 Ctags 生成的标签文件的支持,包括 Ctags、通用 和 Exuberant Ctags。
安装
composer require michaeljoelphillips/ctags-php
使用
您可以使用谓词函数过滤标签,匹配类似于 readtags 的标签,或列出所有标签。每个结果都是一个包含 CTags\Tag 对象的 Generator
use CTags\Reader; use CTags\Tag; use Generator; $reader = Reader::fromFile('tags', true); $reader->listAll(); $reader->match('MyClass'); $reader->partialMatch('My'); $reader->filter(static function (Tag $tag) { return $tag->name === 'MyClass' && $tag->fields['kind'] === 'c'; });
如果读取 Universal Ctags 扩展字段不是必需的,您可以为了更好的性能排除它们
use CTags\Reader; $reader = Reader::fromFile('tags', false);