bingo-functional icon indicating copy to clipboard operation
bingo-functional copied to clipboard

Fatal error when using Nothing::flatMap

Open OlexandrPopov opened this issue 4 years ago • 0 comments

Consider the following code:

$maybe = Maybe::fromValue(null)
    ->flatMap(function () {
        return Maybe::fromValue('some value');
    })
    ->getOrElse('default');

It causes the error: PHP Fatal error: Uncaught Error: Call to a member function getOrElse() on null. Probably Nothing::flatMap should return an instance of Nothing instead of null.

OlexandrPopov avatar Aug 04 '20 07:08 OlexandrPopov