Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement first class callable syntax for instance method references #164

Closed
wants to merge 4 commits into from

Conversation

thekid
Copy link
Member

@thekid thekid commented Apr 15, 2023

Inspired by https://externals.io/message/120011

class Person {
  public function __construct(private string $name) { }
  public function name(): string { return $this->name; }
}

$group= [new Person('Timm'), new Person('Alex')];

// Instead of the following:
$names= array_map(fn($person) => $person->name(), $group);

// ...we can now write this:
$names= array_map(Person->name(...), $group);

// ["Timm", "Alex"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant