Download the PHP package silasyudi/optional without Composer
On this page you can find all versions of the php package silasyudi/optional. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package optional
Optional
Portability of Java's java.util.Optional<T> class to PHP, updated with Java 11 features.
Summary
- Language / Idioma
- Instalation
- Requirements
- Features
- Differences
Language / Idioma
Leia a versão em português :brazil: aqui.
Instalation
Requirements
- PHP 7.4+
- Composer
Features
The Optional class encapsulates a value and can perform various operations on it.
Example without Optional:
Example with Optional:
Differences
Some differences could not be avoided due to the particularities of each language. The most important are listed below:
Optional.stream()of the Java was not imported into this package, as it doesn't have something similar in PHP and already has similar methods inmap,flatMapandfilter.Optional.hashCode()was not imported into this package.NullPointerExceptioneNoSuchElementExceptionof the Java was replaced byOptionalInvalidStateExceptionwhen the Optional object cannot be empty andTypeErrorwhen attempting to pass null incallableparameters.Optional.orElseThrowin Java 11 is overloaded, and expects no parameter or a Supplier parameter. In this package, this method expects a Throwable object ornullas parameter.Consumer,Function,PredicateandSupplierwas imported ascallable.
All versions of optional with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.4
The package silasyudi/optional contains the following files
Loading the files please wait ...