Re: pipes, scalar objects and on?
| From: | Olle Härstedt | Date: | Tue, 18 Jul 2023 13:05:25 +0000 |
| Subject: | Re: pipes, scalar objects and on? | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-120834@lists.php.net to get a copy of this message | ||
2023-07-18 14:48 GMT+02:00, someniatko <someniatko@gmail.com>:
> I am glad this topic arose! I was also planning to write on this topic to
> the internals mailing list, but have abandoned this idea, because I feel it
> might be inconvenient for the real active PHP developers on the list to
> receive too many emails from the people which don't actively participate in
> the development itself.
>
> My interest in the pipe operator might seem a little non-standard -
> basically what I'd really want to see is a **nullable** pipe operator!
>
> There is a popular library github.com/schmittjoh/php-option, which has 250
> MILLION installations. Basically what it provides is a class-wrapper of a
> value of lack thereof: it's either
Some<Type> or
> None.
I'd just like to mention that the Option type comes from FP and it's
not necessarily needed in PHP-land where we have flow-sensitive type
checkers like Psalm (a nullable type ?int or such is refined to just
int after a null check). Flow-sensitive type-checking was not
invented when the Option type was first created, so adding it to PHP
is basically stepping back in time, from my point of view.
Olle