Re: [RFC] Mixed type

From: Date: Fri, 24 Apr 2020 12:18:07 +0000
Subject: Re: [RFC] Mixed type
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-109824@lists.php.net to get a copy of this message
On Fri, Apr 24, 2020 at 2:12 PM Bob Weinand <bobwei9@hotmail.com> wrote: > Mixed is in almost every case just patching the holes in PHPs type system. > And as such, I'd rather promote RFCs trying to properly fix the gaps in the > type system than supporting mixed. > > Mixed is a hack, do not use mixed. > Heya Bob, I maintain lots of legacy code and I cannot add return types despite being truly mixed. Mixed is not a hack, it's a scenario that frequently happens. There are lots of use-cases where we explicitly want to mark it as such as it truly accepts anything. Would I use it in new code? Pretty much never, as string|int would already cover the majority of cases, especially where ints are represented by strings. I would love to see mixed being added as it lets me remove a lot of docblocks that are only added so I can indicate mixed. I disagree that it's patching holes, it's filling a gap that's currently missing something. Regards, Lynn

« previous php.internals (#109824) next »