v2.0.0
Breaking Changes
This major release aligns with TOON Specification v2.0, which removes the optional # length marker prefix from array headers.
Removed Features
EncodeOptions::$lengthMarkerparameter removed from constructorEncodeOptions::withLengthMarkers()preset method removedEncodeOptions::withLengthMarker()fluent setter removed
Changed Behavior
- Encoder: Always emits
[N]format (e.g.,[3]: a,b,c) - Decoder: Rejects
[#N]format withSyntaxException
Migration Guide
Before (v1.x):
$options = EncodeOptions::withLengthMarkers();
$toon = Toon::encode($data, $options);
// Output: [#3]: a,b,cAfter (v2.0):
$options = EncodeOptions::default();
$toon = Toon::encode($data, $options);
// Output: [3]: a,b,cFixed
Critical Fixes
- Locale-dependent float formatting: Fixed
sprintf()calls that caused decimal points to become commas in locales likeda_DK,de_DE. Now usesnumber_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\thave 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.mdwith control character policy and v2.0 compliance details - Full TOON Specification v2.0 conformance verified