{"record":{"id":"635f59c678d12669","repo":"twigphp/Twig","slug":"the-style-s-does-not-exist-known-styles-are-s","errorCode":null,"errorMessage":"The style \"%s\" does not exist, known styles are: \"%s\".","messagePattern":"The style \"(.+?)\" does not exist, known styles are: \"(.+?)\"\\.","errorType":"exception","errorClass":"Twig\\Error\\RuntimeError","httpStatus":null,"severity":"error","filePath":"extra/intl-extra/IntlExtension.php","lineNumber":533,"sourceCode":"        }\n\n        $timezoneName = $timezone ? $timezone->getName() : '(none)';\n        $hash = $locale.'|'.$dateFormatValue.'|'.$timeFormatValue.'|'.$timezoneName.'|'.$calendar.'|'.$pattern;\n\n        if (!isset($this->dateFormatters[$hash])) {\n            if (\\count($this->dateFormatters) >= self::MAX_CACHED_FORMATTERS) {\n                array_shift($this->dateFormatters);\n            }\n            $this->dateFormatters[$hash] = new \\IntlDateFormatter($locale, $dateFormatValue, $timeFormatValue, $timezone, $calendar, $pattern);\n        }\n\n        return $this->dateFormatters[$hash];\n    }\n\n    private function createNumberFormatter(?string $locale, string $style, array $attrs = []): \\NumberFormatter\n    {\n        if (!isset(self::NUMBER_STYLES[$style])) {\n            throw new RuntimeError(\\sprintf('The style \"%s\" does not exist, known styles are: \"%s\".', $style, implode('\", \"', array_keys(self::NUMBER_STYLES))));\n        }\n\n        if (null === $locale) {\n            $locale = \\Locale::getDefault();\n        }\n\n        // textAttrs and symbols can only be set on the prototype as there is probably no\n        // use case for setting it on each call.\n        $textAttrs = [];\n        $symbols = [];\n        if ($this->numberFormatterPrototype) {\n            foreach (self::NUMBER_ATTRIBUTES as $name => $const) {\n                if (!isset($attrs[$name])) {\n                    $value = $this->numberFormatterPrototype->getAttribute($const);\n                    if ('rounding_mode' === $name) {\n                        $value = array_flip(self::NUMBER_ROUNDING_ATTRIBUTES)[$value];\n                    } elseif ('padding_position' === $name) {\n                        $value = array_flip(self::NUMBER_PADDING_ATTRIBUTES)[$value];","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/intl-extra/IntlExtension.php#L515-L551","documentation":"createNumberFormatter validates the $style argument against the IntlExtension::NUMBER_STYLES constant before creating a \\NumberFormatter. An unknown style name throws this RuntimeError listing the valid styles.","triggerScenarios":"Calling the format_number or format_currency filters with a style argument not in NUMBER_STYLES — e.g. 'integer', 'percent2', or a misspelled ' Spellout'.","commonSituations":"Typos in template filter arguments; using raw \\NumberFormatter constant names (DECIMAL, SPELLOUT) in lowercase/incorrect string form; dynamic style values from config not validated beforehand.","solutions":["Use only styles listed in the error message / NUMBER_STYLES keys (decimal, currency, percent, scientific, spellout, ordinal, duration, etc.)","Fix the style string in the template or PHP call","Validate dynamic style values against IntlExtension NUMBER_STYLES keys before passing","Fall back to 'decimal' when the configured style is unknown"],"exampleFix":"// before\n{{ 12345.67|format_number(style='numerical') }}\n// after\n{{ 12345.67|format_number(style='decimal') }}","handlingStrategy":"validation","validationCode":"if (!isset(IntlExtension::NUMBER_STYLES[$style])) { throw new \\InvalidArgumentException(\"Unknown number style $style\"); }","typeGuard":"function isKnownNumberStyle(string $s): bool { return isset(IntlExtension::NUMBER_STYLES[$s]); }","tryCatchPattern":"try { $out = $intl->formatNumber($n, $style); } catch (\\Twig\\Error\\RuntimeError $e) { if (str_contains($e->getMessage(), 'style')) { $out = $intl->formatNumber($n, 'decimal'); } else { throw $e; } }","preventionTips":["Map configured styles to known keys at config load time","Reuse a shared constants list matching NUMBER_STYLES","Cover filter styles with unit tests"],"tags":["php","intl","number-formatting","invalid-argument"],"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"}