You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,14 @@
1
1
# CHANGELOG
2
2
3
+
## [4.3.0] - 2026-04-19
4
+
5
+
### Added
6
+
7
+
-**`#[InputKeyTo(KeyCase::X)]`** — Input key case conversion. Apply at class level to remap all incoming array keys before hydration, or at property level to override for a specific property. Conversion splits on camelCase/PascalCase boundaries, underscores, hyphens, and whitespace, then rejoins in the target case.
8
+
-**`#[OutputKeyTo(KeyCase::X)]`** — Output key case conversion. Apply at class level to remap all serialized keys during `toArray(true)` / `toJson(true)`, or at property level to override for a specific property.
-**`InvalidKeyCaseException`** — Thrown at definition time when `#[InputKeyTo]` or `#[OutputKeyTo]` receives a value that is not a `KeyCase` enum instance (e.g. a plain string).
Copy file name to clipboardExpand all lines: README.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -603,6 +603,60 @@ try {
603
603
604
604
By default, the VO and SVO validation chain walks from the top of the inheritance chain down to the current class. With `#[ValidateFromSelf]` applied, the chain is reversed to start from the current class and walk upward.
605
605
606
+
### `#[InputKeyTo]` - Input Key Case Conversion
607
+
608
+
Converts incoming array keys to the specified `KeyCase` naming convention before hydration. Applied at class level, it remaps all keys; applied at property level, it overrides the class-level conversion for that property only.
609
+
610
+
```php
611
+
use ReallifeKip\ImmutableBase\Attributes\InputKeyTo;
Converts property names to the specified `KeyCase` naming convention during serialization. Applied at class level, it remaps all serialized keys; applied at property level, it overrides the class-level conversion for that property only.
627
+
628
+
The argument passed to `toArray()` / `toJson()` controls the conversion behavior:
629
+
-`false` (default): no key conversion — property names are output as-is
630
+
-`true`: applies the `#[OutputKeyTo]`-defined conversion for the current level only — nested objects use their own `#[OutputKeyTo]` declarations independently and are not affected
631
+
-`KeyCase::*`: ignores `#[OutputKeyTo]` and forces the specified case globally
632
+
633
+
```php
634
+
use ReallifeKip\ImmutableBase\Attributes\OutputKeyTo;
@@ -681,6 +735,8 @@ Thrown when class structure or attribute configuration is incorrect. These are p
681
735
682
736
`InvalidSpecException` - `#[Spec]` is used without an argument or with an empty argument.
683
737
738
+
`InvalidKeyCaseException` - `#[InputKeyTo]` or `#[OutputKeyTo]` received a value that is not a `KeyCase` enum instance (e.g. a plain string instead of `KeyCase::Camel`).
739
+
684
740
`InvalidCompareTargetException` - The `equals()` comparison target is not the same class, or an array contains a non-ImmutableBase object that cannot be compared.
685
741
686
742
`InvalidWithPathException` - A `with()` deep path targets a scalar property that cannot be traversed further.
0 commit comments