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.
Consider the following code:
It causes the error:
PHP Fatal error: Uncaught Error: Call to a member function getOrElse() on null. ProbablyNothing::flatMapshould return an instance ofNothinginstead ofnull.