mini\Converter\ConverterRegistryInterface::replace()
Method
public
abstract
Signature
public abstract function replace(mini\Converter\ConverterInterface|Closure $converter, ?string $targetName = NULL, ?string $sourceName = NULL): void
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$converter |
mini\Converter\ConverterInterface|Closure |
required | Documentation missing |
$targetName |
?string |
NULL
|
Documentation missing |
$sourceName |
?string |
NULL
|
Documentation missing |
Returns
void
Documentation
Replace an existing converter
Similar to register() but allows overriding existing converters without throwing conflicts. Useful for customizing default framework converters.
If no converter exists for the given input→output type combination, behaves identically to register().
When replacing a union converter, all member type aliases are updated to point to the new converter.
Example:
// Override the default string→Response converter
$registry->replace(function(string $text): ResponseInterface {
return new Response(200, ['Content-Type' => 'text/html'], "<p>$text</p>");
});