Re: [RFC] [Discussion] #[\Deprecated] for interfaces

From: Date: Mon, 23 Nov 2026 21:20:51 +0000
Subject: Re: [RFC] [Discussion] #[\Deprecated] for interfaces
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-133211@lists.php.net to get a copy of this message
Hi On 2026-11-22 23:34, Daniel Scherzer wrote:
3. The proposal makes sense to me and I agree that there is no room for further “improvements” regarding deprecating interfaces. Extending an interface and implementing an interface is the two places where an interface actively gets used. Neither instanceof or using an interface in a type declaration should warn, since there is no way to avoid the deprecation there without actually making a breaking change. Those are “passive” consumers of an interface. It probably makes sense to at least spell out in the RFC how these consumers were considered and why they don't emit the deprecation notice.
I added a note that these do not trigger deprecation warnings.
Pet peeve of mine: The RFC says “typehint”. It should read “type declaration”. Those are not hints, they are enforced. I would also like to ask for *some* blurb of justification of why they don't trigger a deprecation for public record of the decision making. If you agree with my arguments, you can put them (more eloquently phrased :-)) into the RFC texts. ----------- I also realized another situation where the warning could potentially end up being quite noisy. Using your example:
    #[\Deprecated]
    interface BaseInterface {}
    interface ChildInterface extends BaseInterface {}
    class ImplementsChild implements ChildInterface {}
Consider that both interfaces are defined in (different) libraries. As a user of ChildInterface I can't directly do anything about the deprecation, and should not: ChildInterface is not deprecated. But if the author of the ChildInterface library now does an update and deprecates its ChildInterface in response to the upstream deprecation:
    #[\Deprecated]
    interface BaseInterface {}
    #[\Deprecated]
    interface ChildInterface extends BaseInterface {}
    class ImplementsChild implements ChildInterface {}
Then two deprecation warnings will be emitted, with the BaseInterface one technically being already “acted on” by the library author of ChildInterface by passing along the deprecation. If that makes sense. My suggestion would thus be to suppress any deprecations “higher” in the type hierarchy if the interface (or in future scope class) is deprecated itself. So the second example would just emit the deprecation for ChildInterface, but not the one for BaseInterface. Best regards Tim Düsterhus

« previous php.internals (#133211) next »