phalcon/cphalcon · error · Phalcon\Tag\Exception
{message}
Error message
{message} What it means
Phalcon\Tag::friendlyTitle() is the static facade over the Friendly helper. It catches every \Exception the helper throws and rethrows it as Phalcon\Tag\Exception, keeping the original message — so '{message}' is the helper's error text, in practice almost always 'Parameter replace must be an array or a string' (InvalidReplaceFormat) from a badly typed 4th argument. The exception type is Tag\Exception, not the specific helper exception.
Source
Thrown at phalcon/Tag.zep:327
/**
* Converts texts into URL-friendly titles
*
* @phpstan-param array<array-key, string>|string $replace
*/
public static function friendlyTitle(
string text,
string separator = "-",
bool lowercase = true,
var replace = null
) -> string
{
var ex;
try {
return (new Friendly())->__invoke(text, separator, lowercase, replace);
} catch \Exception, ex {
throw new Exception(ex->getMessage());
}
}
/**
* Internally gets the request dispatcher
*/
public static function getDI() -> <DiInterface>
{
if (null === self::container) {
let self::container = Di::getDefault();
}
return self::container;
}
/**
* Get the document type declaration of content
*/View on GitHub (pinned to b7419de9cd)
Solutions
- Pass a valid $replace — a string or an array of strings — or omit the parameter
- Catch Phalcon\Tag\Exception and read getMessage(): it mirrors the helper's error, so fix the named parameter
- For precise exception types, call (new Friendly())(...) directly instead of the Tag facade
Example fix
// before echo \Phalcon\Tag::friendlyTitle($post->title, '-', true, $post->stripCode); // after echo \Phalcon\Tag::friendlyTitle($post->title, '-', true, ['-', '_']);
Defensive patterns
Strategy: validation
Validate before calling
if (null !== $replace && !is_string($replace) && !is_array($replace)) {
$replace = []; // Tag rethrows the helper's error as Tag\Exception
}
echo \Phalcon\Tag::friendlyTitle($title, '-', true, $replace); Type guard
function isValidTagFriendlyReplace($replace): bool
{
return null === $replace || is_string($replace) || is_array($replace);
} Try / catch
try {
echo \Phalcon\Tag::friendlyTitle($title, '-', true, $replace);
} catch (\Phalcon\Tag\Exception $e) {
// getMessage() mirrors the helper's error, e.g.
// "Parameter replace must be an array or a string"
$logger->warning($e->getMessage());
echo \Phalcon\Tag::friendlyTitle($title, '-', true);
} Prevention
- Validate the $replace argument where it enters your system (config/DB), not in the template
- Prefer the typed Friendly helper over the Tag facade when you need specific exception classes
- Log Tag\Exception messages — they name the exact parameter at fault
When it happens
Trigger: Phalcon\Tag::friendlyTitle($title, '-', true, 123) or with true as $replace — the helper throws InvalidReplaceFormat and Tag wraps it as Tag\Exception with the same message.
Common situations: View templates calling Tag::friendlyTitle with a replace value sourced from config or a record attribute whose type is wrong; static helper calls in legacy view code that bypass the typed helper API.
Related errors
- Parameter 'using' requires two values
- Views directory must be a string or an array
- Views directory item must be a string
- View '{viewPath}' was not found in any of the views director
- A dependency injection container is required to access appli
AI-assisted analysis of phalcon/cphalcon@b7419de9cd (2026-08-21).
Data as JSON: /api/errors/474f286c5210ad3d.
Report an issue: GitHub.