@@ -120,18 +120,19 @@ $param->schema();
120120
121121### Core types
122122
123- | Type | Helper | Attribute | Description |
124- | --------------------- | ---------- | ----------- | ----------------------------------------- |
125- | [ String] ( #string ) | ` string ` | ` _string ` | String, optionally matching a regex |
126- | [ Int] ( #int ) | ` int ` | ` _int ` | Integer with optional range/accept/reject |
127- | [ Float] ( #float ) | ` float ` | ` _float ` | Float with optional range/accept/reject |
128- | [ Bool] ( #bool ) | ` bool ` | ` _bool ` | Boolean |
129- | [ Null] ( #null ) | ` null ` | ` _null ` | Null |
130- | [ Object] ( #object ) | ` object ` | — | Object of a given class |
131- | [ Mixed] ( #mixed ) | ` mixed ` | ` _mixed ` | Any type |
132- | [ Array] ( #array ) | ` arrayp ` | ` _arrayp ` | Array with named parameters |
133- | [ Iterable] ( #iterable ) | ` iterable ` | ` _iterable ` | Iterable with generic key/value |
134- | [ Union] ( #union ) | ` union ` | ` _union ` | Value matching at least one parameter |
123+ | Type | Helper | Attribute | Description |
124+ | ------------------------ | ----------- | ------------ | --------------------------------------------- |
125+ | [ String] ( #string ) | ` string ` | ` _string ` | String, optionally matching a regex |
126+ | [ Int] ( #int ) | ` int ` | ` _int ` | Integer with optional range/accept/reject |
127+ | [ Float] ( #float ) | ` float ` | ` _float ` | Float with optional range/accept/reject |
128+ | [ Bool] ( #bool ) | ` bool ` | ` _bool ` | Boolean |
129+ | [ Null] ( #null ) | ` null ` | ` _null ` | Null |
130+ | [ Object] ( #object ) | ` object ` | — | Object of a given class |
131+ | [ Mixed] ( #mixed ) | ` mixed ` | ` _mixed ` | Any type |
132+ | [ Array] ( #array ) | ` arrayp ` | ` _arrayp ` | Array with named parameters |
133+ | [ Iterable] ( #iterable ) | ` iterable ` | ` _iterable ` | Iterable with generic key/value |
134+ | [ Union] ( #union ) | ` union ` | ` _union ` | Value matching at least one parameter |
135+ | [ UnionNull] ( #union-null ) | ` unionNull ` | ` _unionNull ` | Value matching at least one parameter or null |
135136
136137### Derived types
137138
@@ -522,6 +523,8 @@ $union('100'); // '100'
522523$union(100); // 100
523524```
524525
526+ ## UnionNull
527+
525528You can also use ` unionNull() ` as a shorthand for nullable unions:
526529
527530``` php
@@ -536,13 +539,11 @@ $maybeInt(null); // null
536539Attribute notation:
537540
538541``` php
539- use Chevere\Parameter\Attributes\_union;
540- use Chevere\Parameter\Attributes\_float;
542+ use Chevere\Parameter\Attributes\_null;
541543use Chevere\Parameter\Attributes\_int;
542544
543- #[_union(
544- new _int(),
545- new _float()
545+ #[_unionNull(
546+ new _int()
546547)]
547548```
548549
0 commit comments