Question

Recently, i gave up Taglist for Tagbar. Tagbar works as expected for all languages except PHP. It lists class, methods and variables into their respective categories instead of displaying methods and variables into their respective scope.

I came to know that ctags has poor support for PHP.

Is there any way to improve ctags and Tagbar's support for PHP? I am hopping for some kind of hack or tweak, or any other way around.

Was it helpful?

Solution

I have just using PHP_Parser as syntax parsing backend written a tool called phpctags to generate ctags compatiable index file and an addon plugin for tagbar called tagbar-phpctags to enhance the PHP suport for tagbar.

Methods and properties even local variables assigned in functions could be listed in their own scope now as well as their access information.

Maybe these could help.

OTHER TIPS

Unfortunately there is no easy answer to this. The ctags PHP parser just uses regular expressions, and the result -- as you noticed -- is that support for scopes is missing.

There would be two ways to get proper scope support working: someone has to write either an actual recursive parser module for ctags, or some other program that can output tags in a ctags compatible format. That could theoretically even be written in PHP, which might make it easier -- maybe there already is some functionality available that allows access to the AST, which would then just need to be printed out in the correct format. But until someone does that I'm afraid there's no real way to properly display PHP scopes in Tagbar, since it has to rely on the information that ctags hands to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top