Ocramius.util.Optional
:package: A PHP port of java.util.Optional as in the OpenJDK
Install / Use
/learn @Ocramius/Ocramius.util.OptionalREADME
ocramius\util\Optional
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.
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。


