{"record":{"id":"77a95eff8c15ef09","repo":"twigphp/Twig","slug":"the-type-s-does-not-exist-known-types-are-s","errorCode":null,"errorMessage":"The type \"%s\" does not exist, known types are: \"%s\".","messagePattern":"The type \"(.+?)\" does not exist, known types are: \"(.+?)\"\\.","errorType":"exception","errorClass":"Twig\\Error\\RuntimeError","httpStatus":null,"severity":"error","filePath":"extra/intl-extra/IntlExtension.php","lineNumber":387,"sourceCode":"            return [];\n        }\n    }\n\n    public function formatCurrency($amount, string $currency, array $attrs = [], ?string $locale = null): string\n    {\n        $formatter = $this->createNumberFormatter($locale, 'currency', $attrs);\n\n        if (false === $ret = $formatter->formatCurrency($amount, $currency)) {\n            throw new RuntimeError('Unable to format the given number as a currency.');\n        }\n\n        return $ret;\n    }\n\n    public function formatNumber($number, array $attrs = [], string $style = 'decimal', string $type = 'default', ?string $locale = null): string\n    {\n        if (!isset(self::NUMBER_TYPES[$type])) {\n            throw new RuntimeError(\\sprintf('The type \"%s\" does not exist, known types are: \"%s\".', $type, implode('\", \"', array_keys(self::NUMBER_TYPES))));\n        }\n\n        $formatter = $this->createNumberFormatter($locale, $style, $attrs);\n\n        if (false === $ret = $formatter->format($number, self::NUMBER_TYPES[$type])) {\n            throw new RuntimeError('Unable to format the given number.');\n        }\n\n        return $ret;\n    }\n\n    public function formatNumberStyle(string $style, $number, array $attrs = [], string $type = 'default', ?string $locale = null): string\n    {\n        return $this->formatNumber($number, $attrs, $style, $type, $locale);\n    }\n\n    /**\n     * @param \\DateTimeInterface|string|null  $date     A date or null to use the current time","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/intl-extra/IntlExtension.php#L369-L405","documentation":"formatNumber validates the $type argument against the list of types supported by NumberFormatter (default, decimal, currency, percent, scientific, spellout, ordinal, duration, etc.). This is a generic argument-validation guard: it fires whenever formatNumber is called with a $type string that is not one of these known type names, e.g. a typo like 'deciaml' or an unsupported style, so the error names the bad type and enumerates the valid alternatives.","triggerScenarios":"Calling twig format_number(..., type: 'float') or format_number_style with a type string outside the allowed set, or a typo like 'decmial'.","commonSituations":"Copy-pasting style names into the type argument; user-configurable formatting options not whitelisted; upgrading and expecting a type that never existed.","solutions":["Use one of the listed known types: default, int (integer), currency, percent, etc. as shown in the message.","Fix typos in the type string.","Whitelist/validate the type in config before passing.","Use the style argument (decimal, percent, scientific...) rather than type for formatting styles."],"exampleFix":"// before\nformat_number($n, type: 'float')\n// after\nformat_number($n, type: 'default')","handlingStrategy":"validation","validationCode":"$known = ['default','int','currency','percent']; if (!in_array($type, $known, true)) { $type = 'default'; }","typeGuard":"function isKnownNumberType(string $t): bool { return array_key_exists($t, \\Symfony\\Bridge\\Twig\\Extension\\IntlExtension::NUMBER_TYPES ?? []); }","tryCatchPattern":"try { $s = format_number($n, type: $type); } catch (Twig\\Error\\RuntimeError $e) { $s = format_number($n); }","preventionTips":["Only pass types from the constant, never user input unfiltered","Distinguish style vs type arguments","Read the error message: it lists all valid types"],"tags":["intl","enum","number-format"],"backgroundTag":"invalid-enum-value","analyzedSha":"a414c3a491defb5a60f2fc88ef79ff37c90010cd","analyzedAt":"2026-09-13T15:10:46.849Z","contentChangedAt":"2026-09-13T15:10:46.849Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}