Re: [VOTE] First-class callable syntax

From: Date: Fri, 02 Jul 2021 16:31:53 +0000
Subject: Re: [VOTE] First-class callable syntax
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115276@lists.php.net to get a copy of this message
This RFC uses a syntax that is forward-compatible with partial function application. Should it not be accepted, I'll explore alternative syntax possibilities.
Given the choice of syntax in this proposal (which I do like)... Is the following (potentially future) use case precluded by the syntax (whether or not you like it immediately ;) )? Basically be able to: 1. be able to refer to an instance method statically (this is currently an error) 2. allow late binding of $this/context/closure scope, either via bindTo() or via Reflection setClosureThis() (does not exist) class MyController {
    public function myAction($name) {
      return new Response("Hello, $name");
    }
} // Closure with no $this (to be filled in later) $fn = MyController->myAction(...); $controller = new MyController; $response = ($fn->bindTo($controller))($params); -ralph

« previous php.internals (#115276) next »