{"record":{"id":"74aca5e930cd3ddb","repo":"twigphp/Twig","slug":"the-list-width-s-does-not-exist-known-widths-are-s","errorCode":null,"errorMessage":"The list width \"%s\" does not exist, known widths are: \"%s\".","messagePattern":"The list width \"(.+?)\" does not exist, known widths are: \"(.+?)\"\\.","errorType":"exception","errorClass":"Twig\\Error\\RuntimeError","httpStatus":null,"severity":"error","filePath":"extra/intl-extra/IntlExtension.php","lineNumber":620,"sourceCode":"        foreach ($symbols as $name => $value) {\n            $this->numberFormatters[$hash]->setSymbol(self::NUMBER_SYMBOLS[$name], $value);\n        }\n\n        return $this->numberFormatters[$hash];\n    }\n\n    private function createListFormatter(?string $locale, string $type, string $width): \\IntlListFormatter\n    {\n        $listTypes = self::availableListTypes();\n\n        if (!isset($listTypes[$type])) {\n            throw new RuntimeError(\\sprintf('The list type \"%s\" does not exist, known types are: \"%s\".', $type, implode('\", \"', array_keys($listTypes))));\n        }\n\n        $listWidths = self::availableListWidths();\n\n        if (!isset($listWidths[$width])) {\n            throw new RuntimeError(\\sprintf('The list width \"%s\" does not exist, known widths are: \"%s\".', $width, implode('\", \"', array_keys($listWidths))));\n        }\n\n        if (null === $locale) {\n            $locale = \\Locale::getDefault();\n        }\n\n        $listTypeValue = $listTypes[$type];\n        $listWidthValue = $listWidths[$width];\n\n        $hash = $locale.'|'.$listTypeValue.'|'.$listWidthValue;\n\n        if (!isset($this->listFormatters[$hash])) {\n            if (\\count($this->listFormatters) >= self::MAX_CACHED_FORMATTERS) {\n                array_shift($this->listFormatters);\n            }\n            $this->listFormatters[$hash] = new \\IntlListFormatter($locale, $listTypeValue, $listWidthValue);\n        }\n","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/intl-extra/IntlExtension.php#L602-L638","documentation":"createListFormatter validates the $width argument (list width variant, e.g. 'wide'/'narrow') against IntlExtension::availableListWidths(). An unknown width throws this RuntimeError listing the supported widths.","triggerScenarios":"Calling the format_list filter (formatList -> createListFormatter) with a width argument not in availableListWidths() — e.g. 'condensed', 'long', or a typo like 'wiede'.","commonSituations":"Typos in template arguments; assuming other ICU width names are supported; config- or user-supplied width values never validated against availableListWidths().","solutions":["Use only widths listed in the error (keys of availableListWidths(): 'wide', 'short', 'narrow')","Fix the width string in the template or PHP call","Validate configured widths against availableListWidths() before rendering","Omit width to use the default 'wide'"],"exampleFix":"// before\n{{ items|format_list(width='condensed') }}\n// after\n{{ items|format_list(width='narrow') }}","handlingStrategy":"validation","validationCode":"if (!isset(IntlExtension::availableListWidths()[$width])) { throw new \\InvalidArgumentException(\"Unknown list width $width\"); }","typeGuard":"function isKnownListWidth(string $w): bool { return isset(IntlExtension::availableListWidths()[$w]); }","tryCatchPattern":"try { $out = $intl->formatList($strings, $type, $width); } catch (\\Twig\\Error\\RuntimeError $e) { if (str_contains($e->getMessage(), 'list width')) { $out = $intl->formatList($strings, $type, 'wide'); } else { throw $e; } }","preventionTips":["Restrict width choices to 'wide'/'short'/'narrow'","Validate config-driven widths at startup","Omit width when unsure (defaults to 'wide')"],"tags":["php","intl","list-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"}