schmittjoh/php-option — pull request #18 by psliwa (2014-09-02 21:42:20+00:00)
Title: Change Some::map() method semantics

When callback passed to map method returns `null`, `Some(null)` object will be returned. This behaviour is the same as in Scala, but I have doubts this behaviour meets php world correctly. I think in scala `map` works in that way, because `null` value in this language should not be used at all, so `map` method should never return `null`.

In java8 on the other hand when callback produces null value, the `None` is returned.This behaviour differs from scala, because in java `null` is a normal value - it is fully supported by the language from the begining. I think the `null` value in php also is not unusual, so `Some` should take into accout that callback is able to return `null` value and handle this in natural for php way. Thanks to that behaviour, `Option` would be safer, it would be possible that code:

```php
//helper function
function prop($name) { ... }

$email = Option::fromValue($employee)
->map(prop('boss'))
//if boss is null, None will be returned so we can safetly invoke another map, filter etc.
->map(prop('email'))
->getOrElse('fallback@example.com');
```

I know there is `flatMap` that supports Option as return value of callback - but this enforces whole our code in every level and every layer to use `Option` type.