Skip to content

Releases: tuxonice/data-transfer-object

v1.2.0

Choose a tag to compare

@tuxonice tuxonice released this 10 Aug 07:59
fd260a8
fix: Fix invalid code generated for a plain array type (#18)

A property declared "type": "array" produced a class that does not parse.
Unlike string[] or FooTransfer[], a plain array carries no element type, and
three places assumed one was always present:

- macros.twig emitted both initialisers for a nullable array, giving
  `private ?array $body = [] = null;`
- class.twig appended an "add" method to every array property, so with no
  element type or singular it emitted `public function add( $): self`
- the @var, @return and @param docblocks rendered the element type
  unconditionally, giving `array<>` and `array|null<>`, and placed the
  generic after |null

DefinitionProvider now handles a plain array explicitly, documenting it as
array<mixed> and leaving the singular unset. The add method is emitted only
when a singular exists, and the initialiser is chosen rather than
concatenated: null when nullable, [] otherwise.

Only definitions that previously produced invalid PHP change. The existing
expected-output fixtures are untouched, which is what shows scalars, typed
arrays, transfer arrays and namespaced classes still generate byte for byte
as before.

A plain array may now be nullable. The typed-array restriction is unchanged,
since ArrayTypeNullableException still guards types ending in [].

Fixtures live in tests/Data/PlainArray so the shared Data set, and the tests
asserting against it, stay as they are.

v1.1.2

Choose a tag to compare

@tuxonice tuxonice released this 05 Apr 18:39
[DTO-19] Cleanup output folder before regeneration

v1.1.1

Choose a tag to compare

@tuxonice tuxonice released this 30 Jan 20:26

[DTO-18] Improve jsonSchema validation

  • add schema definitions to not repeat
  • add multiple sub-schemas to handle array cases
  • add more tests

v1.1.0

Choose a tag to compare

@tuxonice tuxonice released this 12 Jan 13:35
  • Export keys in snake case in toArray method
  • increase PHPStan level to 7
  • Improve tests
  • Improve documentation

v1.0.1

Choose a tag to compare

@tuxonice tuxonice released this 07 Jan 09:29
[FIX] Fix wrong package name on readme file

v1.0.0

Choose a tag to compare

@tuxonice tuxonice released this 07 Jan 09:24
[TASK] Update readme file

v0.3.3

Choose a tag to compare

@tuxonice tuxonice released this 24 Nov 18:40
[DTO-13] Update documentation

v0.3.2

Choose a tag to compare

@tuxonice tuxonice released this 22 Nov 21:35
[TASK] Remove renovate

v0.3.1

Choose a tag to compare

@tuxonice tuxonice released this 10 Nov 20:27
[DTO-14] fromArray should only map valid properties

v0.3.0

Choose a tag to compare

@tuxonice tuxonice released this 03 Nov 19:54
Update shivammathur/setup-php digest to 81cd5ae