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
1. ArrayOf
1-1. Added support for native-typed arrays: Native::string, Native::int, Native::float, Native::bool, validating PHP scalar values without requiring SingleValueObject.
1-2. Documentation updated to clarify that Native enums are valid targets for ArrayOf.
2. Writer / ib-writer
2-1. Updated class-level descriptions and usage examples to include TypeScript output support.
2-2. TypeScript (.ts) generation now produces: declare namespace blocks, DTO/VO interfaces, SVO type aliases, and enum/union types for referenced PHP enums.
3. InvalidArrayOfItemException
3-1. Fixed @param count and names to match constructor signature.
3-2. Improved message clarity, distinguishing ImmutableBase class resolution failures from primitive type mismatches.
4. InvalidPropertyTypeException
4-1. Added standalone null to the forbidden property type list.
4-2. Updated message to list allowed types and provide guidance for nullable declarations (?Type or Type|null).
5. InvalidArrayOfTargetException
5-1. Documentation updated to indicate Native can be used as a valid ArrayOf target type.
6. ImmutableBase
6-1. scanNamedType(): clarified that null passes through as a builtin type.
6-2. arrayOfInitialize(): removed phantom @param $propertyName.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,22 @@
1
1
# CHANGELOG
2
2
3
-
## [4.1.1] - 2025-03-07
3
+
## [v4.2.0] - 2026-03-12
4
+
5
+
### Added
6
+
7
+
-**`Native` enum — Primitive typed arrays via `#[ArrayOf]`.**`#[ArrayOf]` now accepts `Native::string`, `Native::int`, `Native::float`, and `Native::bool` to declare arrays of validated PHP scalar values without wrapping them in a SingleValueObject.
8
+
-**`ib-writer` TypeScript output.**`vendor/bin/ib-writer` now supports `.ts` generation, producing `declare namespace` blocks with interfaces for DTO/VO, type aliases for SVO, and enum/union types for referenced PHP enums.
9
+
10
+
### Changed
11
+
12
+
-**Standalone `null` property type is now forbidden.** Declaring a property typed as `null` alone throws `InvalidPropertyTypeException` at scan time. Use `?Type` or `Type|null` for nullable properties.
13
+
-**`InvalidPropertyTypeException` message updated.** Now explicitly lists allowed types and provides nullable usage guidance.
14
+
-**`InvalidArrayOfItemException` message updated.** Now distinguishes between ImmutableBase class resolution failures and primitive type mismatches.
15
+
16
+
## [v4.1.1] - 2025-03-07
4
17
5
18
### Fixed
19
+
6
20
#### ib-writer
7
21
- Property tables now include a `default` column displaying default
8
22
values from `#[Defaults]` attributes and `defaultValues()` overrides
### 📃 Documentation as Code, Code as Documentation
117
117
118
-
🥳 ImmutableBase can scan all subclasses in your project via `vendor/bin/ib-writer`, generating Mermaid class diagrams and Markdown property tables to keep documentation in sync with code.
118
+
🥳 ImmutableBase can scan all subclasses in your project via `vendor/bin/ib-writer`, generating Mermaid class diagrams, Markdown property tables, and TypeScript declarations to keep documentation in sync with code.
119
119
120
120
🫤 The conventional approach cannot guarantee consistency between code and documentation.
121
121
@@ -298,7 +298,7 @@ readonly class ValidAge extends SingleValueObject
298
298
```php
299
299
$age = ValidAge::from(18);
300
300
301
-
echo $age; // 18 (via __toString, only available when $value is a string)
Marks an array property as a typed collection of ImmutableBase instances. Each element is automatically instantiated from arrays, JSON strings, or pre-built objects. The target class must be a subclass of DTO, VO, or SVO.
488
+
Marks an array property as a typed collection of ImmutableBase instances or primitive scalar values. Each element is automatically validated or instantiated. The target must be a subclass of DTO, VO, or SVO, or a `Native` enum case for scalar arrays.
489
+
490
+
**Primitive scalar arrays** can be declared using `Native` enum cases instead of a class name:
491
+
492
+
| Case | PHP type |
493
+
| ---------------- | -------- |
494
+
|`Native::string`|`string`|
495
+
|`Native::int`|`int`|
496
+
|`Native::float`|`float`|
497
+
|`Native::bool`|`bool`|
489
498
490
499
```php
491
500
use ReallifeKip\ImmutableBase\Attributes\ArrayOf;
492
501
493
502
readonly class SignUpUsersDTO extends DataTransferObject
494
503
{
504
+
505
+
// ImmutableBase subclass
495
506
#[ArrayOf(User::class)]
496
507
public array $users;
497
-
public int $userCount;
508
+
509
+
// Primitive scalar array
510
+
#[ArrayOf(Native::string)]
511
+
public array $tags;
512
+
#[ArrayOf(Native::int)]
513
+
public array $scores;
498
514
}
499
515
```
500
516
@@ -637,7 +653,7 @@ vendor/bin/ib-cacher --clear
637
653
638
654
### `writer` - Documentation Generator
639
655
640
-
Generates documentation for all ImmutableBase subclasses in the project. Supports Mermaid class diagrams and Markdown property tables.
656
+
Generates documentation for all ImmutableBase subclasses in the project. Supports Mermaid class diagrams, Markdown property tables, and TypeScript declarations.
641
657
642
658
```bash
643
659
vendor/bin/ib-writer
@@ -720,7 +736,7 @@ This section is provided for v3 migration reference only.
720
736
## Notes
721
737
722
738
1. All subclass properties must be public. Since ImmutableBase is declared as a readonly class, the entire inheritance chain must also be readonly at the PHP language level.
723
-
2. Forbidden property types: `iterable`, `object`, non-ImmutableBase/non-Enum classes such as `DateTime`, `Closure`.
739
+
2. Forbidden property types: `null`, `iterable`, `object`, non-ImmutableBase/non-Enum classes such as `DateTime`, `Closure`.
724
740
3. Enum properties accept case names (`"HIGH"`) or backed values (`3`). The resolved property value is always an Enum instance.
725
741
4.`mixed` type is supported, but values will not be validated.
0 commit comments