Re: Pre-RFC proposal: opt-in implicit interfaces / structural typing

From: Date: Fri, 07 Nov 2025 21:30:49 +0000
Subject: Re: Pre-RFC proposal: opt-in implicit interfaces / structural typing
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-129141@lists.php.net to get a copy of this message
On Fri, Nov 7, 2025, at 1:28 PM, John Bafford wrote: >> I could see implicit interfaces working in conjunction with extension functions, if we can >> figure those out. I'm not sure if they offer much value without them, given the state of PHP. >> It would basically mean you have to opt-out of a type rather than opt-in, as now. That could get... >> weird. >> >> --Larry Garfield > > Opting out would both be weird, and from a practical standpoint, is > unreasonable to ask of userspace developers. > > For correctness, every potential implicit interface match would have to > be explicitly declared as non-comforming in order to be correct. It's > both very noisy and does not scale. From a library perspective, it's > impossible: a library class can't possibly declare all the possible > does_not_implement conformances because the entire universe of > interfaces that might overlap its shape can't be known. OK, maybe opt-out wasn't the right term, since I agree marking "I do NOT implement interface X" is kinda ridiculous. :-) Implicit interfaces wouldn't really be opt-out, but they're more than the opt-in that we currently have. --Larry Garfield

« previous php.internals (#129141) next »