Skip to content

[Feature]: View references for view names returned from methods (component template registry) #1365

Description

@EgorGruzdev

Description

We use a lightweight Twig component model on top of TwigBridge. Each component
class declares its template via a static method returning the view name; the
actual view() call happens later inside a central Twig extension:

class Header implements TwigComponent
{
    public static function template(): string
    {
        return 'components/corporate/header'; // ← view name, but not recognized
    }
}

// elsewhere, in the Twig extension:
return view($componentClass::template(), $context)->render();

Since the string literal is not an argument of view() / View::make(),
Laravel Idea does not recognize it as a view reference — no completion,
no click-navigation to the template, no "unresolved view" inspection,
and the template file itself is reported as unused.

What we tried

  • ide.json completions with "complete": "views" — works only for method
    arguments, not for return values.
  • Current workaround: return view('components/corporate/header')->name();
    — the literal becomes visible to Laravel Idea, at the cost of instantiating
    a View object at runtime (we cache the resolved name per request).

Proposal

Any of these would solve it:

  1. ide.json support for marking a method's return value as a view
    reference, e.g. "place": "returnValue" in a completion definition;
  2. or an attribute the plugin recognizes, e.g. #[ViewName] on the method /
    a class-level #[View('components/...')];
  3. or recognizing view-name strings returned from methods implementing a
    configurable interface.

This would also help other "registry" patterns where view names live in
constants/config arrays rather than direct view() calls.

Plugin version: Laravel Idea 13.2.0.261
PhpStorm version: PhpStorm 2026.1.3 (PS-261.25134.104)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions