Skip to content

Anonymous classes are not treated as final #7904

@MidnightDesign

Description

@MidnightDesign

Bug report

PHPStan should treat anonymous classes as final.

Code snippet that reproduces the problem

interface Test {
	public static function create(): static;
}

$impl = new class implements Test {
	public static function create(): static {
		return new self();
	}
};

https://phpstan.org/r/9c7e89f4-0572-4bc8-b5ad-374c6f73071e

Method class@anonymous/tmp.php:7::create() should return static(class@anonymous/tmp.php:7) but returns class@anonymous/tmp.php:7.

Expected output

No issues reported by PHPStan.

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