componenta/default-value
Composer 安装命令:
composer require componenta/default-value
包简介
Default value sentinel for Componenta packages
README 文档
README
Single marker enum for distinguishing an omitted default value from an explicit null.
Use it in APIs where null is a meaningful caller-provided value and cannot also mean "argument was not provided".
Installation
composer require componenta/default-value
Related Packages
| Package | Why it matters here |
|---|---|
componenta/di |
Uses DefaultValue::None in attributes where null can be an explicit default. |
componenta/config |
Useful for APIs that distinguish an omitted fallback from a null fallback. |
Usage
use Componenta\Stdlib\DefaultValue; function readOption(string $name, mixed $default = DefaultValue::None): mixed { if ($default === DefaultValue::None) { return loadRequiredOption($name); } return loadOptionalOption($name, $default); }
Passing null remains explicit:
readOption('cache.ttl', null); // default is intentionally null
Contract
DefaultValue::None means no default value was provided. It is intentionally a marker, not a container and not a replacement for Option/Maybe value objects.
When To Use
Use this package for function arguments, resolver APIs, config helpers, and factories that need to preserve the difference between:
- no fallback was given
- fallback was given and the fallback is
null
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-14