For a while, I’ve been putting up with the annoying errors in Phpactor that complain about methods like ->where()
not existing on a class. When working with complex methods that call various models, these errors can make the codebase unnecessarily messy to look at.
I finally decided to tackle this issue and figure out how to fix it.
Steps to Disable Phpactor Errors
1. Initialize Phpactor Configuration
Open your terminal, navigate to your project directory, and run the following command:
$ phpactor config:initialize
This will create a .phpactor.json file in the root of your project.
2. Edit the Configuration File
Open the .phpactor.json file and replace its contents with the following:
{
"language_server.diagnostic_ignore_codes": [
"method_is_missing_param",
"worse.docblock_missing_param",
"worse.missing_member",
"worse.unresolved_name"
]
}
Each error code corresponds to a specific type of error that Phpactor reports. Add any additional error codes you want to ignore in this array.
3. Clear Phpactor’s Cache
Run the following command to clear Phpactor's cache:
$ phpactor cache:clear
4. Restart AstroNvim
Quit Neovim and open it again to apply the changes.
Final Thoughts
After following these steps, the unnecessary errors should no longer appear. This tweak has made my workflow much smoother, and I hope it helps anyone else facing a similar issue!