A port of java.util.Optional to PHP
This package is auto-updated.
Last update: 2020-11-01 04:21:14 UTC
This package is a PHP port of the
java.util.Optional class in the
Currently maintained by Niklas Schöllhorn, taken over 3rd March, 2019
You can find the API of
java.lang.Optional in the
Java 8 API docs.
composer require ocramius/optional
Because of PHP's current limitations, I had to rewrite some bits of the Java implementation as follows:
emptyis a reserved PHP keyword
- type-safety is not ensured at any time: generics have simply been stripped from the
Optionalimplementation. This may change in future, but I don't plan to do it right now.
Optional#__toString()in accordance to PHP magic methods naming
Supplierarguments are simply
callable, for simplicity and flexibility.
Since this library is a direct port of the OpenJDK sources, I have to keep the original license in place, which is GPLv2 + ClassPath exceptions.