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

From: Date: Mon, 23 Nov 2026 22:25:11 +0000
Subject: Re: [RFC] [Discussion] #[\Deprecated] for interfaces
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-133212@lists.php.net to get a copy of this message
Hi Tim, On Mon, Nov 23, 2026 at 1:20 PM Tim Düsterhus <tim@bastelstu.be> wrote: > 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. > > Fixed "type declarations", and added rejected features for the reasoning. > ----------- > > 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 > I think this might be a footgun. Consider if the starting situation was ``` interface BaseInterface {} #[\Deprecated] interface ChildInterface extends BaseInterface {} ``` where the two interfaces are defined in different libraries, and the ChildInterface is deprecated for unrelated reasons. If the BaseInterface were to become deprecated in the upstream library, the downstream library wouldn't have any warning. Really, we would want a way to suppress compile-time deprecations, which would be a much more elaborate change - e.g. just reusing @ might not work because we don't want to silence *all* warnings, just the specific one. I've been thinking vaguely about a system like Rust's expect attribute ( https://doc.rust-lang.org/1.100.0/reference/attributes/diagnostics.html#r-attributes.diagnostics.lint.expect) and how that might work, but that is something for further down the road. -Daniel

« previous php.internals (#133212) next »