Releases: php-collective/dto
Releases · php-collective/dto
0.1.17
Fixes
- Make
IoInterface::warning()optional via method annotation, fixing BC break from 0.1.16. Libraries are actually coding against this interface already.
Full Changelog: 0.1.16...0.1.17
0.1.16
Fixes
- DateTimeInterface instantiation - OpenAPI importer now adds
factory: \DateTimewhen mappingdate-time/dateformat fields to\DateTimeInterface, preventing "Cannot instantiate interface" errors (#107) - Add validation warning for interface/abstract types without factory (#109)
Full Changelog: 0.1.15...0.1.16
0.1.15
⚠️ Breaking Changes
Backed Enum Validation (#94)
Invalid backed enum values now throw InvalidArgumentException instead of silently returning null.
// Before: silently sets priority to null (data corruption)
$dto = new AdvancedDto(['priority' => 999]);
$dto->getPriority(); // null
// After: throws InvalidArgumentException
// "Invalid value `999` for backed enum field `priority`. Valid values: 1, 5, 10."Applications relying on the old behavior should add explicit validation before passing values to DTOs.
Fixes
- Associative collection key extraction - Keys are now correctly extracted from pre-instantiated DTO objects (#93)
- Unit enum validation - Invalid case names now throw
InvalidArgumentExceptioninstead of uncatchableError(#94) - read() empty path -
$dto->read([], 'default')now correctly returns the default value (#94) - Pattern validation regex - Fixed escaping in fast-path template for proper PHP string generation (#95)
- Config merge behavior - Fields are now properly merged at the field level instead of overwriting (#96)
- Inflector singularization - Full alignment with custom inflection rules for edge cases like
species,cookies,graffiti(#97) - TypeScript union imports - Fixed missing imports for DTO references inside union types in multi-file output (#103)
Improvements
- Directory permissions - Changed from hardcoded
0755to0777to respect system umask settings (#99) - Template simplification - Moved conditional logic from Twig templates to
TemplateDataPreparerclass for better testability (#100) - Path traversal protection - Validates target paths stay within expected Dto directory, checks for null bytes and
..sequences (#101) - Error handling - Improved error messages with class context, proper multi-line formatting, invalid regex detection, factory return type validation, and removal of
@error suppression (#101) - Generator robustness - TypeScript and JSON Schema generators now fail loudly when unable to create directories or write files (#103)
- Documentation - Updated docs to reflect current lazy fields, validation, readonly, and TypeScript generator capabilities (#102)
Full Changelog: 0.1.14...0.1.15
0.1.14
Fixes
Circular Dependency Detection
- Lazy fields now break circular dependency detection (#84)
- Union types (
Foo|Bar) parsed correctly (#86) - Intersection types (
Foo&Bar) and DNF types supported (#87) singularTypefield now parsed for unions (#87)
Lazy Field Handling
- Template mutators (
set,add,remove,with*) clear_lazyData(#88) hasmethod checks_lazyDatafor lazy fields (#88)- Getter template uses
array_key_exists()for null values (#89) clone()preserves_lazyData(#89)_toArrayInternalchecks_lazyData(fixes serialization) (#90)setFromArrayFasttemplate usesarray_key_exists()(#90)validate()template checks_lazyDatafor required fields (#90)- Base class
validate()andsetDefaults()check_lazyData(#91) *OrFailtemplates handle lazy fields correctly (#91)
Full Changelog: 0.1.13...0.1.14
0.1.13
0.1.12
Improvements
- Add validation rules support (minLength, maxLength, min, max, pattern) for field constraints - #78
- Add lazy properties to defer DTO/collection hydration until first getter access - #78
- Add readonly properties support for language-level immutability - #78
- Add validationRules() method returning framework-agnostic rules for plugin integration - #79
Full Changelog: 0.1.11...0.1.12
0.1.11
Improvements
- Add serialize/unserialize convenience methods and fix associative collection keys - #75
- Fix optimizations template to use collection adapter for append - #76
Full Changelog: 0.1.10...0.1.11
0.1.10
Improvements
- Add serialize/unserialize convenience methods and fix associative collection keys - #74
Full Changelog: 0.1.9...0.1.10
0.1.9
New Features
- Add external file
$refsupport to schema importer (#66) - Add collection remove methods (
withRemovedItem) (#64) - Add field transforms (
transformFrom/transformTo) for DTOs (#65) - Add
JsonSerializablesupport (#63)
Bug Fixes
- Fix immutable array copy -
with*methods now perform defensive copying (#69) - Fix collection key field silent fallback - now throws exception when key missing (#69)
- Fix XML injection in importer schema builder (#68)
Improvements
- Clarify enum handling in importer docs (#67)
Internal
- Benchmark improvements for nested external refs (#62)
Cleanup
- Removed deprecated Serializable interface support in favor of above JsonSerializable (#71)
Full Changelog: 0.1.8...0.1.9