{"record":{"id":"474f286c5210ad3d","repo":"phalcon/cphalcon","slug":"message-474f28","errorCode":null,"errorMessage":"{message}","messagePattern":"\\{message\\}","errorType":"exception","errorClass":"Phalcon\\Tag\\Exception","httpStatus":null,"severity":"error","filePath":"phalcon/Tag.zep","lineNumber":327,"sourceCode":"\n    /**\n     * Converts texts into URL-friendly titles\n     *\n     * @phpstan-param array<array-key, string>|string $replace\n     */\n    public static function friendlyTitle(\n        string text,\n        string separator = \"-\",\n        bool lowercase = true,\n        var replace = null\n    ) -> string\n    {\n        var ex;\n\n        try {\n            return (new Friendly())->__invoke(text, separator, lowercase, replace);\n        } catch \\Exception, ex {\n            throw new Exception(ex->getMessage());\n        }\n    }\n\n    /**\n     * Internally gets the request dispatcher\n     */\n    public static function getDI() -> <DiInterface>\n    {\n        if (null === self::container) {\n            let self::container = Di::getDefault();\n        }\n\n        return self::container;\n    }\n\n    /**\n     * Get the document type declaration of content\n     */","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/phalcon/cphalcon/blob/b7419de9cd0a8a3f48441ead84c9f8415d463e25/phalcon/Tag.zep#L309-L345","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\necho \\Phalcon\\Tag::friendlyTitle($post->title, '-', true, $post->stripCode);\n\n// after\necho \\Phalcon\\Tag::friendlyTitle($post->title, '-', true, ['-', '_']);","handlingStrategy":"validation","validationCode":"if (null !== $replace && !is_string($replace) && !is_array($replace)) {\n    $replace = []; // Tag rethrows the helper's error as Tag\\Exception\n}\n\necho \\Phalcon\\Tag::friendlyTitle($title, '-', true, $replace);","typeGuard":"function isValidTagFriendlyReplace($replace): bool\n{\n    return null === $replace || is_string($replace) || is_array($replace);\n}","tryCatchPattern":"try {\n    echo \\Phalcon\\Tag::friendlyTitle($title, '-', true, $replace);\n} catch (\\Phalcon\\Tag\\Exception $e) {\n    // getMessage() mirrors the helper's error, e.g.\n    // \"Parameter replace must be an array or a string\"\n    $logger->warning($e->getMessage());\n    echo \\Phalcon\\Tag::friendlyTitle($title, '-', true);\n}","preventionTips":["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"],"tags":["phalcon","tag","view","slug"],"backgroundTag":"invalid-parameter-type","analyzedSha":"b7419de9cd0a8a3f48441ead84c9f8415d463e25","analyzedAt":"2026-08-21T06:21:18.811Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}