Skip to content

Constructor property promotion and backslash as a namespace operator cause false positive for UndefinedVariable bug #331

Closed
@yokozawa0701

Description

@yokozawa0701

Here's a simple example that generates UndefinedVariable for using Constructor property promotion and backslash as a namespace operator.

class Test
{
    public function __construct(
        public \App\Models\User $user,  // Unused function parameter $user. (VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable)
    ) {}
}
use App\Models\User;

class Test
{
    public function __construct(
        public User $user,  // Thid is no error.
    ) {}
}

I am using v2.11.19.
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions