Partial Function Application for instance of non-static methods ("$this")#27
Partial Function Application for instance of non-static methods ("$this")#27arnaud-lb wants to merge 39 commits intopartials-v2-genfrom
Conversation
RFC: https://wiki.php.net/rfc/partial_function_application_v2 Co-authored-by: Joe Watkins <krakjoe@php.net>
fff0684 to
81530d0
Compare
TimWolla
left a comment
There was a problem hiding this comment.
Can you also include:
<?php
class Foo {
public function dump(...$args) {
var_dump($args);
}
}
$f = Foo::dump(this: ?, ...);
$f(new Foo(), ...['this' => 'foo']);
as a test to make it clear that this: and 'this' unpacking can be combined?
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Invalid use of 'this' placeholder in %s on line %d |
There was a problem hiding this comment.
If possible the error message could be clearer here:
The 'this' placeholder may only be used on methods
or similar. I'll check existing error messages for a proper suggestion if/when the RFC passes.
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Fatal error: Invalid parameter name: this in %s on line %d |
There was a problem hiding this comment.
Similarly:
The 'this' parameter must be a placeholder
this should probably not fail. This comes from the rename of Would it be possible to introduce a fallback instead, whereby |
|
Yes it's a compromise to avoid adding special cases in the engine to support What we could probably do, is to set the param name to |
88ff9da to
5b844c6
Compare
RFC: https://wiki.php.net/rfc/partial_function_application_this