Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

NancyJames's avatar

VS Code Extensions - for deep inheritance

I'm having a problem with VS Code not recognising functions when there's deep inheritance (at least I think that's the issue)

Eg. I have a class that extends another class that extends formrequest which extends request - and its the request functions that are coming up as unknown (eg. $this->user, $this->input, $this->has, $this->route_is). The code runs fine because those methods do exist but I don't know what I need to do to get VS Code to acknowledge it.

0 likes
2 replies
LaryAI's avatar
Level 58

Certainly! This is a common issue in VS Code, especially with PHP projects that have deep inheritance chains (like Laravel's FormRequestRequest). VS Code itself doesn't provide deep PHP analysis out of the box, but you can fix this with the right extensions and some configuration.

Recommended Solution:

  1. Install PHP Intelephense

    This is the most popular and powerful PHP language server for VS Code. It provides advanced autocompletion, type inference, and deep inheritance recognition.

    • Go to Extensions (Ctrl+Shift+X)
    • Search for Intelephense and install it.
  2. (Optional) Install Laravel Extra Intellisense

    If you’re working with Laravel, this extension adds even more context and autocompletion for Laravel-specific features.

    • Search for Laravel Extra Intellisense and install it.
  3. Check Your Workspace Settings

    Make sure your workspace is using the correct PHP version and that your vendor folder is not excluded from indexing. In your .vscode/settings.json:

    {
        "intelephense.environment.phpVersion": "8.1", // or your PHP version
        "intelephense.files.exclude": [
            "**/.git/**",
            "**/node_modules/**",
            "**/bower_components/**"
        ]
    }
    
  4. Regenerate Intelephense Index

    Sometimes, Intelephense needs to re-index your project. Open the command palette (Ctrl+Shift+P) and run:

    Intelephense: Index workspace
    
  5. Add PHPDoc Annotations (if needed)

    If you have custom methods or properties injected by Laravel (like $this->user() in requests), you can help Intelephense by adding PHPDoc annotations:

    /**
     * @method \App\Models\User|null user()
     */
    class MyFormRequest extends FormRequest
    {
        // ...
    }
    

Summary

  • Install Intelephense (and optionally Laravel Extra Intellisense)
  • Ensure your workspace is configured correctly
  • Re-index if needed
  • Use PHPDoc for custom magic methods

This should resolve your issue with VS Code not recognizing inherited methods like $this->user, $this->input, etc.

Let me know if you need more help!

Please or to participate in this conversation.