Skip to content

Maybe Nullable (Plugins)

Compare
Choose a tag to compare
@devosc devosc released this 18 Sep 16:46
· 112 commits to master since this release

Previously a shared service value could not be null; because the PHP function isset only returns true when the value is not null. Consequently, if a shared service previously returned null, the service would be called again the next time the shared value is retrieved. In order to resolve this, two new plugins and an empty object have been created, Maybe, Nullable and Nothing.

The Maybe plugin can be used to return Nothing when a value is null. The Nullable plugin can then be used to return null when the value is Nothing. Additionally, the Maybe plugin can be used as a null coalescing operator by configuring it to return a default value (or plugin configuration) instead of returning Nothing.

(new App)(new Maybe(null, 'foo')); //foo