Formats an assertion message string.
Unlike format_string(),
string $message: The assertion message string containing placeholders.
array $args: An array of replacement token values to inject into $message.
string The $message with exported replacement tokens, sanitized for HTML output.
protected function formatString($message, array $args) {
array_walk($args, function (&$value) {
// Export/dump the raw replacement token value.
$value = var_export($value, TRUE);
// Sanitize the value for output.
$value = htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
// Wrap the value in a PRE element if it contains newlines.
if (strpos($value, "\n")) {
$value = '<pre style="white-space: pre-wrap;">' . $value . '</pre>';
}
});
return strtr($message, $args);
}