Skip to content

Anonymous classes and Type declarations cause false positive for UndefinedVariable bug #332

@yokozawa0701

Description

@yokozawa0701

Here's a simple example that generates UndefinedVariable for using Anonymous classes and Type declarations.

class Test { public int $id = 1; // This is no error. public function test_1(): object { return new class { public int $id = 123456; // Unused variable $id. (VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable) }; } public function test_2(): object { return new class { public $id = 123456; // This 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