ocramius/optional

This package is abandoned and no longer maintained. The author suggests using the whsv26/functional package instead.

A port of java.util.Optional to PHP

Maintainers

๐Ÿ‘ Ocramius

Package info

github.com/Ocramius/ocramius.util.Optional

Homepage

pkg:composer/ocramius/optional

Statistics

Installs: 263

Dependents: 0

Suggesters: 0

Stars: 24

Open Issues: 9

1.0.0 2019-03-12 10:02 UTC

Requires

  • php: ^7.3

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>

javaoptional


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 named Optional#newEmpty(), because empty is a reserved PHP keyword
  • type-safety is not ensured at any time: generics have simply been stripped from the Optional implementation. This may change in future, but I don't plan to do it right now.
  • Optional#toString() is named Optional#__toString() in accordance to PHP magic methods naming
  • Consumer, Predicate, Function and Supplier arguments are simply callable, 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.