Say you want a helper method on a class you don't own, like DateTimeImmutable. Today you'd write a wrapper class or a plain function. This RFC from Holly Schilling lets you add methods to an existing class or interface from outside its definition, and PHP only uses them when the class doesn't already have a method with that name. The idea comes from Swift and C#.
Show me
Here is the RFC's example:
extension \DateTimeImmutable $date { public function isWeekend(): bool { return in_array((int)$date->format('N'), [6, 7], true); } } var_dump((new DateTimeImmutable('2026-07-11'))->isWeekend()); // bool(true)
The $date after the class name is the receiver, the object the method is called on, and you use it instead of $this. In fact, $this isn't allowed inside an extension.
The rules
- The class always wins. If the class has its own method with that name, PHP calls that one.
- Public only. Extension code sees the object the way outside code does, so it can't touch private or protected members.
- Methods only. No properties, constants or magic methods like
__toString(). - No mixing with
__call. If a class has__call(), extensions never run for it. - Interfaces work too. An extension on an interface acts like a default method for classes that don't define one, but it doesn't count toward what the interface requires.
- Load it first. An extension exists once its file is included, just like a function.
- Reflection doesn't see them.
ReflectionClass::getMethods()won't list extension methods.
Extensions on strings and other scalar values are covered in a separate RFC that builds on this one.
Performance
Normal method calls don't change, because PHP only looks for an extension where it would throw "Call to undefined method" today. The RFC says calling an extension method currently costs about the same as going through __call.
What it means for existing code
The RFC expects nothing to break. extension only acts as a keyword when another name follows it, so a class, function or method named extension still works. IDEs and static analyzers will need to learn the new syntax.
Where it stands
The RFC is a draft, on version 1.4 as of July 11, 2026, and there's a working patch. Several questions are still open, like what happens when two extensions add the same method. The plan is a yes or no vote that needs a two-thirds majority.