Skip to content

v2.0.0

Choose a tag to compare

@HelgeSverre HelgeSverre released this 13 Nov 10:40
· 16 commits to main since this release

Breaking Changes

This major release aligns with TOON Specification v2.0, which removes the optional # length marker prefix from array headers.

Removed Features

  • EncodeOptions::$lengthMarker parameter removed from constructor
  • EncodeOptions::withLengthMarkers() preset method removed
  • EncodeOptions::withLengthMarker() fluent setter removed

Changed Behavior

  • Encoder: Always emits [N] format (e.g., [3]: a,b,c)
  • Decoder: Rejects [#N] format with SyntaxException

Migration Guide

Before (v1.x):

$options = EncodeOptions::withLengthMarkers();
$toon = Toon::encode($data, $options);
// Output: [#3]: a,b,c

After (v2.0):

$options = EncodeOptions::default();
$toon = Toon::encode($data, $options);
// Output: [3]: a,b,c

Fixed

Critical Fixes

  • Locale-dependent float formatting: Fixed sprintf() calls that caused decimal points to become commas in locales like da_DK, de_DE. Now uses number_format() with explicit decimal separator for locale-independent formatting per TOON Spec §2.

Security

  • Control character handling: Strings containing unsupported control characters (0x00-0x08, 0x0B, 0x0C, 0x0E-0x1F) are now rejected with InvalidArgumentException. Only \n, \r, and \t have defined escape sequences per TOON Spec §7.1.

Bug Fixes

  • Decoder error messages: Pattern [N#] now produces correct v2.0 error message

Test Coverage

  • Added 10 tests for v2.0 breaking change verification
  • Added 5 tests for control character rejection
  • Total: 544 tests, 997 assertions (100% passing)
  • PHPStan Level 9: 0 errors

Documentation

  • Updated docs/SPEC-COMPLIANCE.md with control character policy and v2.0 compliance details
  • Full TOON Specification v2.0 conformance verified