Re: [RFC] Pattern Matching
| From: | Dmitry Derepko | Date: | Wed, 03 Dec 2025 04:32:02 +0000 |
| Subject: | Re: [RFC] Pattern Matching | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129521@lists.php.net to get a copy of this message | ||
> On Dec 3, 2025, at 12:03 AM, Larry Garfield <larry@garfieldtech.com> wrote:
>
> $filtered = array_filter($arr, is Point(x: <10));
Btw, it looks incorrect and short closure is preferable here
array_filter($arr, fn($x) => $x is Point())
Or if it works with DFA
array_filter($arr, ? is Point())
If your example illustrated a pattern as an argument I think it’s not valid case, because a
pattern is something after “is”? The point, enumerated types or values. And “is” here is an
action/function/intention to match left and right operands.
But kotlin style is perfectly matched here
array_filter($arr, { $it is Point() })
--
Best regards,
Dmitrii Derepko.
@xepozz