Edit: Regarding a specific problem, if you have an old version of phpcomplete.vim, it is possible that you can only complete the variable correctly by marking it with the special phpdoc tag ( see this question ) or by regenerating the tag file after declaring the variable.
In all likelihood, you are not doing anything wrong; PHP support in ctags is extremely simple and not very strict, which, unfortunately, also means lack of Vim support. A quick look at the ctags module illustrates the problem:
ctags / php.c
What is it. Just a few basic regular expressions. This parser material below is not used anywhere, and tragically was not very long.
The combination of the problem is that the standard omnicomplete function for PHP in Vim is hacker at best; suffice it to say that it includes a transition between all open windows as part of the process of its completion (a practice clearly condemned by the Vim documentation). See for yourself:
phpcomplete.vim / autoload / phpcomplete.vim
For a long time I struggled with the terrible termination of PHP in Vim and decided that nothing but a complete revision would bring a satisfactory result. I joined the ctags dev mailing list and I plan to improve PHP support there before moving on to making Vim omnicompletion work as much as possible in an interpreted language. At the moment, unfortunately, the solution is to wait until the support is better, or fix it yourself.
Quinn strahl
source share