Skip to content

First class callable syntax for instance methods #23093

Description

@rela589n

Description

Consider the following code:

class Booking
{
    public function getFreeCancellationDeadline(): ?\DateTimeImmutable
    {
          //  ....
    }
}

Then, you'd like to have a closure:

fn (Booking $b): ?\DateTimeImmutable => $b->getFreeCancellationDeadline();

It would be much neater to have it like this:

Booking::getFreeCancellationDeadline(...);

This is the exact form in which PhpStorm IDE copies the method reference ("Copy Reference" on the method - Ctrl+Alt+Sft+C).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions