ocramius/optional
A port of java.util.Optional to PHP
Maintainers
Requires
- php: ^7.3
Requires (Dev)
- doctrine/coding-standard: ^5.0
- infection/infection: ^0.12.2
- phpunit/phpunit: ^8.0.4
- squizlabs/php_codesniffer: ^3.4.0
- vimeo/psalm: ^3.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
GPL-2.0 170f11bc735dc5d08e4aa0e148c68685de3b4130
- Marco Pivetta <ocramius.woop@gmail.com>
- Niklas Schรถllhorn <schoellhorn.niklas.woop@gmail.com>
This package is auto-updated.
Last update: 2021-09-19 03:48:45 UTC
README
๐ Build Status
๐ Scrutinizer Code Quality
๐ Code Coverage
๐ Latest Stable Version
๐ Latest Unstable Version
๐ License
This package is a PHP port of the java.util.Optional class in the
OpenJDK libraries.
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.
Installation
composer require ocramius/optional
Differences with the Java implementation
Because of PHP's current limitations, I had to rewrite some bits of the Java implementation as follows:
Optional#empty()is namedOptional#newEmpty(), becauseemptyis 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()is namedOptional#__toString()in accordance to PHP magic methods namingConsumer,Predicate,FunctionandSupplierarguments are simplycallable, for simplicity and flexibility.
License
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.
