Skip to content

A PHP library for reading tag files generated by Ctags

Notifications You must be signed in to change notification settings

michaeljoelphillips/ctags-php

Repository files navigation

ctags-php

Build Status PHPStan Enabled

This library provides support for reading tag files generated by various versions of Ctags, including Universal and Exuberant Ctags.

Installation

composer require michaeljoelphillips/ctags-php

Usage

You can filter tags using a predicate function, match tags similar to readtags, or list all tags. The result for each is a Generator containing CTags\Tag objects:

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';
});

If reading the Universal Ctags extension fields is not necessary, you can exclude them for better performance:

use CTags\Reader;

$reader = Reader::fromFile('tags', false);

About

A PHP library for reading tag files generated by Ctags

Topics

Resources

Stars

Watchers

Forks

Languages