Skip to content

Releases: php-collective/dto

0.1.17

30 Mar 23:01

Choose a tag to compare

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

30 Mar 19:49
305f23c

Choose a tag to compare

Fixes

  • DateTimeInterface instantiation - OpenAPI importer now adds factory: \DateTime when mapping date-time/date format 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

23 Mar 22:19
5b32a8b

Choose a tag to compare

⚠️ 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 InvalidArgumentException instead of uncatchable Error (#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 0755 to 0777 to respect system umask settings (#99)
  • Template simplification - Moved conditional logic from Twig templates to TemplateDataPreparer class 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

23 Mar 03:37
42cf41a

Choose a tag to compare

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)
  • singularType field now parsed for unions (#87)

Lazy Field Handling

  • Template mutators (set, add, remove, with*) clear _lazyData (#88)
  • has method checks _lazyData for lazy fields (#88)
  • Getter template uses array_key_exists() for null values (#89)
  • clone() preserves _lazyData (#89)
  • _toArrayInternal checks _lazyData (fixes serialization) (#90)
  • setFromArrayFast template uses array_key_exists() (#90)
  • validate() template checks _lazyData for required fields (#90)
  • Base class validate() and setDefaults() check _lazyData (#91)
  • *OrFail templates handle lazy fields correctly (#91)

Full Changelog: 0.1.13...0.1.14

0.1.13

26 Feb 10:17
7847e85

Choose a tag to compare

Improvements

  • Support for sebastian/diff v8

Full Changelog: 0.1.12...0.1.13

0.1.12

09 Feb 02:52
df6b7db

Choose a tag to compare

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

07 Feb 13:04
4496cdb

Choose a tag to compare

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

07 Feb 09:18
a5da0d0

Choose a tag to compare

Improvements

  • Add serialize/unserialize convenience methods and fix associative collection keys - #74

Full Changelog: 0.1.9...0.1.10

0.1.9

06 Feb 14:06
471b2bb

Choose a tag to compare

New Features

  • Add external file $ref support to schema importer (#66)
  • Add collection remove methods (withRemovedItem) (#64)
  • Add field transforms (transformFrom/transformTo) for DTOs (#65)
  • Add JsonSerializable support (#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

0.1.8

01 Feb 07:56
598b5c6

Choose a tag to compare

Improvements

  • Improved DTO from and to paths by multiple factors

Full Changelog: 0.1.7...0.1.8