Skip to content

[static::class, 'method'] is not considered a valid callable #1971

@Jean85

Description

@Jean85

Summary of a problem or a feature request

[self::class, 'method'] is considered a valid callable, [static::class, 'method'] is not.

Code snippet that reproduces the problem

https://phpstan.org/r/ace739fe-efd0-47ef-a0c9-ef439d30d374

<?php declare(strict_types = 1);

class HelloWorld
{
	public function sayHello(): void
	{
		echo 'Hello';
	}

	public function getClosure(): void
	{
		$closure1 = \Closure::fromCallable([self::class, 'sayHello']);
		$closure2 = \Closure::fromCallable([static::class, 'sayHello']); // error
	}
}

Expected output

No errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions