Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

phpactor can't find standard functions and classes definitions#2952

notstronglinuxuser started this conversation inGeneral
Discussion options

phpactor can't find standard functions and classes definitions.

Let me explain in details:

  1. I have fresh arch linux installed withneovim v0.11.5 andphp 8.4.14,phpactor is version2025.10.17.0 is installed viaMason lsp-manager into neovim

  2. I have a project for testing:

$ cat index.php<?phpuse \Exception;class Hello {    public function hello(): void {    }}(new Hello())->hello();throw new Exception();str_contains("a", "abc");
  1. I have installed jetbrains/phpstorm-stubs in this project:
$ cat composer.json{    "require-dev": {        "jetbrains/phpstorm-stubs": "^2024.3"    }}
  1. I configured phpactor with .phpactor.json file in project directory like this:
$ cat .phpactor.json{    "$schema": "/phpactor.schema.json",    "worse_reflection.stub_dir": "%project_root%/vendor/jetbrains/phpstorm-stubs",    "indexer.stub_paths": ["%project_root%/vendor/jetbrains/phpstorm-stubs"],    "indexer.enabled_watchers": ["inotify"],    "indexer.exclude_patterns": ["node_modules/*"]}
  1. I cleared cache and index like this:
phpactor cache:clearphpactor index:clean

(it is the same phpactor, I linked it:sudo ln -s ~/.local/share/nvim/mason/bin/phpactor /usr/local/bin/phpactor)

  1. When I try "Ctrl + ]" (go to definition) onHello class it is fine. But then I try the same onstr_contains orException it fails with the following message:
File "phar:///home/dev/.local/share/nvim/mason/packages/phpactor/phpactor.phar/vendor/jetbrains/phpstorm-stubs/Core/Core_c.php" does not exist.

The file itself IS exist, by the way:

$ ls -la /home/dev/.local/share/nvim/mason/packages/phpactor/phpactor.phar-rw-r--r-- 1 dev dev 4367440 Nov  5 09:16 /home/dev/.local/share/nvim/mason/packages/phpactor/phpactor.phar
  1. At the same time config dump show the following:
$ phpactor config:dump | grep stub    "worse_reflection.stub_dir": "%project_root%\/vendor\/jetbrains\/phpstorm-stubs",    "indexer.stub_paths": [        "%project_root%\/vendor\/jetbrains\/phpstorm-stubs",        "phar:\/\/\/home\/dev\/.local\/share\/nvim\/mason\/packages\/phpactor\/phpactor.phar\/vendor\/jetbrains\/phpstorm-stubs"
  1. :LspInfo in nvim shows:
vim.lsp: Active Clients ~- phpactor (id: 1)  - Version: 2025.10.17.0  - Root directory: /home/dev/test_project  - Command: { "phpactor", "language-server" }  - Settings: {}  - Attached buffers: 1

BTW, sometimes (I don't remember when exactly) I got the following errors in LSP log file:

[ERROR][2025-11-05 12:30:10] ...p/_transport.lua:36     "rpc"   "phpactor"      "stderr"        "In TextDocumentUri.php line 82:\n"[ERROR][2025-11-05 12:30:10] ...p/_transport.lua:36     "rpc"   "phpactor"      "stderr"        '                                                    \n  URI for file:// must be absolute, got "file://."  \n

I have tried to create config in<home>/.config directory (withcomposer global install jetbrains/phpstorm-stubs before it):

> cat ~/.config/phpactor/phpactor.json{    "$schema": "/phpactor.schema.json",    "worse_reflection.stub_dir": "/home/dev/.config/composer/vendor/jetbrains/phpstorm-stubs",    "indexer.stub_paths": ["/home/dev/.config/composer/vendor/jetbrains/phpstorm-stubs"],    "indexer.enabled_watchers": ["inotify"],    "indexer.exclude_patterns": ["node_modules/*"]}

But nothing changed.

phpactor status is:

$ phpactor statusVersion: 2025.10.17.0Filesystems: git, simple, composerWorking directory: /home/dev/test_projectConfig files (missing is not bad):  ✔ /home/dev/.config/phpactor/phpactor.json  ✘ /home/dev/.config/phpactor/phpactor.yml  ✔ /home/dev/test_project/.phpactor.json  ✘ /home/dev/test_project/.phpactor.ymlDiagnostics:  ✔ Composer detected - Phpactor could work faster without an index  ✔ Git detected - enables faster refactorings in your repository scope!  ✔ XDebug is disabled. XDebug has a negative effect on performance.  ✔ Path "/home/dev/test_project" is trusted and configuration will be loaded from it.

I spentso much time on this problem. Tried to debug phpactor source code. But nothing works. And I have no idea what to do next. Why doesn't it work? 😢

You must be logged in to vote

Replies: 3 comments 2 replies

Comment options

Well... I found out ugly solution, I guess...

  1. I downloadeddev-master build ofphpactor (just by cloning this repository and switch tomaster branch) and installed it's deps (composer install inside dir).
  2. I commented the following line inlib/Phpactor.php (line 146):
$config[IndexerExtension::PARAM_STUB_PATHS][] = self::resolveApplicationRoot() . '/vendor/jetbrains/phpstorm-stubs';

and added this line instead:

$config[IndexerExtension::PARAM_STUB_PATHS] = [];
  1. So myphpactor config:dump show this:
$ phpactor config:dump | grep stub    "worse_reflection.stub_dir": "%project_root%\/vendor\/jetbrains\/phpstorm-stubs\/",    "indexer.stub_paths": [],
  1. I reconfiguredMason to use cloned version ofphpactor (just changed symlinks):
/home/dev/.local/share/nvim/mason/bin$ ls -lahtotal 12Kdrwxr-xr-x 2 dev dev 4.0K Nov  5 15:03 ./drwxr-xr-x 7 dev dev 4.0K Nov  5 09:16 ../lrwxrwxrwx 1 dev dev   23 Nov  5 09:16 gopls -> ../packages/gopls/gopls*lrwxrwxrwx 1 dev dev   36 Nov  5 15:03 phpactor -> /home/projects/phpactor/bin/phpactor*
  1. My nvim's :LspInfo shows:
vim.lsp: Active Clients ~- phpactor (id: 1)  - Version: dev-master  - Root directory: /home/dev/project  - Command: { "phpactor", "language-server" }  - Settings: {}  - Attached buffers: 1, 3, 7, 17, 18
  1. I changed myproject.phpaction.json to:
{    "$schema": "/phpactor.schema.json",    "language_server_php_cs_fixer.enabled": true,    "worse_reflection.stub_dir": "%project_root%/vendor/jetbrains/phpstorm-stubs/",    "indexer.enabled_watchers": ["inotify"],    "indexer.exclude_patterns": ["node_modules/*"]}

Project still contain stubs in it's vendor directory:

$ cat composer.json{    "require-dev": {...        "jetbrains/phpstorm-stubs": "^2024.3"...    }}
  1. I removed my "home" config:
rm ~/.config/phpactor/ -rf
  1. And finally dropped caches:
phpactor cache:clear

And now(crossing fingers) after reindex the project it works! I can go to definition of different "parts" of stub from different versions of PHP and different extensions. Such asprint_r,str_contains,Exception,Throwable and EVENSoapClient.

You must be logged in to vote
0 replies
Comment options

I have installed jetbrains/phpstorm-stubs in this project:

why have you done that?

You must be logged in to vote
1 reply
@notstronglinuxuser
Comment options

Because if I install stubs somewhere else nvim runs two instances of phpactor (two language servers at the same time). I don't know why, I just started to learn all this. Anyway, nvim switches between instances by some rules that I don't understand. And behavior that I get is like:well, uhm, I don't know what function it is... Oh, you pressedCtrl + ] second time? Now I know what it is! Seems like nvim (or phpactor) think that there are two projects, not one.

Comment options

But then I try the same on str_contains or Exception it fails with the following message:

that's expected with the stub You can't jump to definition as the stub is in the PHAR. You can however look at the "hover" information, looking at the stub source code might be nice, but actually not required as you can read the docs and methd signature in the hover information.

Alternatively you can install Phactor without the PHAR and it will work as you expected without any other changes.

You must be logged in to vote
1 reply
@notstronglinuxuser
Comment options

but actually not required as you can read the docs and methd signature in the hover information

I respect it. But after using PhpStorm (and other JB products) for years I developed a habit - I like to jump right in source code of standard library and read it (and I do the same with Go, Java, etc...). (Not sure do you know or not, but In PhpStorm jump into stub works perfectly.)

It is very-very comfortable when I just don't remember, let's say, what string functions exist and want to see them all.

Alternatively you can install Phactor without the PHAR and it will work as you expected without any other changes.

Little problem with it is that Mason (plugin for nvim for autoinstall LSP, Linters and so on) can only install phar-version of phpactor, as far as I know. And in the end I have a situation when everything installed via Mason and phpactor installed manually, but via Mason, haha. Some kind of solution I described in my second post in this discussion, but yeah, it's ugly.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
2 participants
@notstronglinuxuser@dantleech
Converted from issue

This discussion was converted from issue #2951 on November 05, 2025 17:15.


[8]ページ先頭

©2009-2025 Movatter.jp