Skip to content

Support Matrix

This page describes what the library supports today, what is partial, and what is not implemented yet.

It is intentionally narrower than a blanket "full TOML support" claim. The goal is to document observed behavior that is backed by the current code and test suite.

The sections below intentionally separate parsing/decoding, encoding, and round-trip editing so support claims stay scoped to the actual surface being described.

The default API behavior is TOML 1.1-compatible. Strict TOML 1.0 parsing/decoding and encoding are available through TomlVersion::V10 and EncoderOptions(version: TomlVersion::V10).

Status Legend

  • Supported: implemented and covered by tests
  • Partial: implemented in a limited way, or decoder and encoder differ
  • Not Yet: not implemented, not preserved, or intentionally out of scope today

Parsing and Decoding

Keys and Tables

FeatureStatusNotes
Bare keysSupported
Quoted keysSupportedBasic and literal quoted keys are accepted
Empty quoted keysSupportedExample: "" = 1
Dotted keysSupported
Standard tablesSupported
Array of tablesSupportedNested array-of-tables is covered by tests
Duplicate key detectionSupportedRejected as semantic errors
Duplicate table detectionSupportedRejected as semantic errors
Key/table redefinition conflictsSupportedRejected as semantic errors

Values

FeatureStatusNotes
Basic stringsSupported
Literal stringsSupported
Multiline basic stringsSupported
Multiline literal stringsSupported
\u and \U escapesSupported
\xHH escapesSupportedTOML 1.1; rejected in strict TOML 1.0 mode
\e escapeSupportedTOML 1.1; rejected in strict TOML 1.0 mode
Invalid escape rejectionSupported
IntegersSupportedDecimal, hex, octal, binary
Float valuesSupportedIncludes exponent form
inf, -inf, nanSupported
Boolean valuesSupported
Offset datetimeSupported
Local datetimeSupportedOptional-seconds forms are rejected in strict TOML 1.0 mode
Local dateSupported
Local timeSupportedOptional-seconds forms are rejected in strict TOML 1.0 mode

Collections

FeatureStatusNotes
ArraysSupported
Multiline arraysSupported
Array trailing commasSupported
Inline tablesSupportedSingle-line and multiline
Nested inline tablesSupported
Dotted keys inside inline tablesSupported
Inline table trailing commasSupportedTOML 1.1; rejected in strict TOML 1.0 mode
Multiline inline tablesSupportedTOML 1.1; rejected in strict TOML 1.0 mode

Encoding

FeatureStatusNotes
StringsSupportedEncoded as basic strings
IntegersSupported
FloatsSupported
BooleansSupported
ArraysSupported
Nested tablesSupported
Array of tablesSupported
Quoted keys when neededSupported
DateTimeInterfacePartialEncoded as offset datetime with microseconds and offset
PhpCollective\Toml\Value\LocalDateSupportedEncoded as local date literal
PhpCollective\Toml\Value\LocalTimeSupportedEncoded as local time literal; strict TOML 1.0 mode normalizes missing seconds
PhpCollective\Toml\Value\LocalDateTimeSupportedEncoded as local datetime literal; strict TOML 1.0 mode normalizes missing seconds
Plain string to local temporal literal coercionNot YetPlain strings are emitted as quoted strings
Null valuesSupportedRejected with EncodeException
Original lexical style preservationPartialencodeDocument() can preserve parsed key and string styles; strict TOML 1.0 source-aware output rejects preserved 1.1-only syntax

AST and Round-Trip Editing

FeatureStatusNotes
AST node accessSupported
Span informationSupported
Trivia preservation on document items and table entriesPartialAvailable through Toml::parse($input, true) for leading/trailing trivia on parsed items
Trivia preservation inside parsed arrays and inline tablesPartialCollection-local item spacing and comments are preserved where represented in the AST
Comment preservation on re-encodePartialPreserved for parsed document items, table entries, and collection items when trivia is available
Formatting preservation on re-encodePartialAvailable in DocumentFormattingMode::SourceAware for trivia-preserving ASTs, including local spacing preservation for common single-line collection edits
encodeDocument() round-trip fidelityPartialNormalized by default; source-aware mode is lossless for unchanged parsed regions, while edited regions preserve local style when inferable and otherwise canonicalize locally

Tooling and Errors

FeatureStatusNotes
Toml::decode()SupportedThrows ParseException on invalid input
Toml::tryParse()SupportedReturns collected parse and semantic errors
Multiple error collectionPartialRecovery exists, but is line-oriented and not conformance-grade
Error spans and formattingSupported

Known Gaps

  • The decoder supports more TOML temporal forms than the encoder can emit.
  • AST editing falls back to canonical local formatting when new nodes do not carry trivia or when single-line collection shape changes do not expose a consistent delimiter style to preserve.
  • Fallback behavior is local rather than globally lossless: nested edited collections may normalize while outer layout stays preserved.
  • Small value-only edits can preserve original key/value separator spacing.
  • Inline table formatting options beyond key sorting and newline selection are not implemented.

toml-test Compliance

Tested against toml-test v2.1.0:

TOML 1.1

Test TypePassedFailedCompliance
Valid4280100%
Invalid4660100%

TOML 1.0

Test TypePassedFailedCompliance
Valid4100100%
Invalid4730100%

These results were measured against the library's bin/toml-decoder adapter for the toml-test tagged JSON format. TOML 1.1 results use the default adapter mode; TOML 1.0 results use TOML_VERSION=1.0 so the decoder runs in strict TOML 1.0 mode.

Strict TOML 1.0 mode closes the previously documented invalid-case gaps for syntax that TOML 1.1 relaxes: multiline inline tables, inline-table trailing commas, \xHH byte escapes, and optional seconds in local times/datetimes.

This library is well suited for:

  • parsing and validating TOML configuration files
  • collecting syntax and semantic errors for IDE/tooling integration
  • encoding PHP arrays into TOML
  • round-trip editing with comment and formatting preservation
  • AST-based TOML analysis and transformation

Released under the MIT License.