Re: [Early Feedback] Pattern matching

From: Date: Thu, 20 Jun 2024 21:05:24 +0000
Subject: Re: [Early Feedback] Pattern matching
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-123712@lists.php.net to get a copy of this message
On Thu, Jun 20, 2024, at 8:29 PM, Thomas Bley wrote: >> https://wiki.php.net/rfc/pattern-matching > Thank you! > >> $var is *; // Matches anything, more useful in the structure patterns below. > > maybe also consider: > > $var is mixed; // Matches anything, more useful in the structure patterns below. :thinking face emoji: That should actually already work naturally through the type support. And should indeed match anything, so... maybe we'll drop the wildcard and just document to use mixed for that? It's a bit more to type, but should be pretty self-explanatory and eliminates a syntax, so... We'll consider this further. >> // Array application, apply a pattern across an array >> $foo is array<strings>; // All values in $foo must be strings >> $foo is array<int|float>; // All values in $foo must be ints or floats > > +1 > > Regards > Thomas --Larry Garfield

« previous php.internals (#123712) next »