mini\Converter\ConverterRegistry class

Documentation

Registry for type converters

Manages converters that transform values from one type to another. Supports union input types and automatic resolution to most specific converter.

Features:

  • Union input types (e.g., string|int)
  • Single-type converters can override union members (more specific wins)
  • Detects conflicting registrations (overlapping unions, duplicates)
  • Type hierarchy resolution for objects (class → interfaces → parent → parent interfaces)
  • Fallback handler for type families (e.g., all BackedEnums)

Resolution order:

  • Direct single-type converter (most specific)
  • Union type converter via alias (less specific)
  • Parent class converters
  • Interface converters
  • Fallback handler (if registered)

Inheritance

Implements: mini\Converter\ConverterRegistryInterface

Properties (2)

private array $converters

Converters indexed by target type, then input type

public readonly mini\Hooks\Handler $fallback

Fallback handler for conversions without registered converters

Methods (12)

Documentation missing

Register a converter

Replace an existing converter

Internal registration logic

Check if a converter exists for input to target type

Get the converter for input to target type

Convert a value to target type

Try to convert a value, returning null if no converter handles it

Find most specific converter for input to target type

Look up a converter for specific input type to target type

Normalize input type string into a canonical key and list of member types.

Walk the type hierarchy for an object

Source

src/Converter/ConverterRegistry.php:29-398