rfc:partial_function_application_this

PHP RFC: Partial Function Application for instance of non-static methods ("$this")

  • Version: 1.0
  • Date: 2026-01-16
  • Author: Tim Düsterhus (tim@tideways-gmbh.com), Arnaud Le Blanc (arnaud.lb@gmail.com)
  • Status: Draft
  • Implementation: https://github.com/...

Introduction

The elevator pitch for the RFC. The first paragraph of this section will be rendered slightly larger to give it emphasis.

Please write an introduction that helps people by providing concise context and include a representative small code snippet.

<?php
 
echo "Showcase your idea here";
 
?>

Proposal

All the features and examples of the proposal.

To paraphrase Zeev Suraski, explain how the proposal brings substantial value to be considered for inclusion in one of the world's most popular programming languages.

Please clearly specify the desired syntax and semantics of your proposal, for example the interactions with existing PHP functionality, and please mention all edge cases, including potential gotchas.

Include stubs for newly introduced functions classes and constants, including namespaces and types.

<?php
 
namespace Example\Component {
    final class NewAddition {
        public static function fromString(string $example): self {}
    }
}
 
?>

Examples

Simple example:

<?php
 
$dates = [
    new DateTimeImmutable('now'),
];
 
$formattedDates = array_map(DateTimeImmutable::format($this: ?, "c"), $dates);
 
?>

Backward Incompatible Changes

None. The proposed syntax currently is a syntax error.

Proposed PHP Version(s)

Next PHP 8.x (8.6).

RFC Impact

To the Ecosystem

Partial Function Application itself is not yet released and it is unlikely that the ecosystem already adapted to it. Thus this additional proposal only has a small incremental impact, most notably by the new $this: named parameter which is “magic” in that it does not refer to an actual parameter name, contains the leading dollar-sign ($) and may appear at the start of the argument list before all positional parameters.

To Existing Extensions

None.

To SAPIs

None.

Open Issues

None.

Future Scope

None.

Voting Choices

Primary Vote requiring a 2/3 majority to accept the RFC:

Implement Partial Function Application for $this as described?
Real name Yes No Abstain
Final result: 0 0 0
This poll has been closed.

Patches and Tests

Links to proof of concept PR.

If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed.

Implementation

After the RFC is implemented, this section should contain:

  1. the version(s) it was merged into
  2. a link to the git commit(s)
  3. a link to the PHP manual entry for the feature

References

Rejected Features

None.

Changelog

  • 2026-01-16: Initial version.
rfc/partial_function_application_this.txt · Last modified: by timwolla