It would theoretically be:
$fn = MyController::myAction(...);
It currently errors:
Fatal error: Uncaught Error: Non-static method MyController::myAction() cannot be called statically
I would be okay with allowing this, as long as it's bound before it's called.
One other question regarding the current patch. I have not seen this aspect discussed yet.
From the list in the first proposal section (https://wiki.php.net/rfc/first_class_callable_syntax#proposal), I am focusing this question on the few that are by name (strings).. so:
strlen(...);
Foo::method(...);
$classStr::$methodStr(...);
self::{$complex . $expression}(...);
'strlen'(...);
[Foo::class, 'method'](...);
Do these have to scan the target function and its signature in order to wrap them? In the cases of classes above, this will trigger the autoloader. I wonder if it could create a by-name reference that resolves the signature at just in time / at call time in these situations?
In context, suppose I am suggesting that something like:
$routes = [
'/my-action' => MyController::myAction(...),
'/other-action => [OtherController::class, 'otherAction'](...),
...
];
would not invoke the autoloader until one of them may be actually used/called.
This would be similar in philosophy as to how Foo::class creates a fully qualified string without confirming a class exists at that name when the scanner and executor sees ::class.
-ralph