{"record":{"id":"36fd0842fd8555fb","repo":"twigphp/Twig","slug":"the-number-formatter-padding-position-s-does-not-exist-known","errorCode":null,"errorMessage":"The number formatter padding position \"%s\" does not exist, known positions are: \"%s\".","messagePattern":"The number formatter padding position \"(.+?)\" does not exist, known positions are: \"(.+?)\"\\.","errorType":"exception","errorClass":"Twig\\Error\\RuntimeError","httpStatus":null,"severity":"error","filePath":"extra/intl-extra/IntlExtension.php","lineNumber":589,"sourceCode":"                array_shift($this->numberFormatters);\n            }\n            $this->numberFormatters[$hash] = new \\NumberFormatter($locale, self::NUMBER_STYLES[$style]);\n        }\n\n        foreach ($attrs as $name => $value) {\n            if (!isset(self::NUMBER_ATTRIBUTES[$name])) {\n                throw new RuntimeError(\\sprintf('The number formatter attribute \"%s\" does not exist, known attributes are: \"%s\".', $name, implode('\", \"', array_keys(self::NUMBER_ATTRIBUTES))));\n            }\n\n            if ('rounding_mode' === $name) {\n                if (!isset(self::NUMBER_ROUNDING_ATTRIBUTES[$value])) {\n                    throw new RuntimeError(\\sprintf('The number formatter rounding mode \"%s\" does not exist, known modes are: \"%s\".', $value, implode('\", \"', array_keys(self::NUMBER_ROUNDING_ATTRIBUTES))));\n                }\n\n                $value = self::NUMBER_ROUNDING_ATTRIBUTES[$value];\n            } elseif ('padding_position' === $name) {\n                if (!isset(self::NUMBER_PADDING_ATTRIBUTES[$value])) {\n                    throw new RuntimeError(\\sprintf('The number formatter padding position \"%s\" does not exist, known positions are: \"%s\".', $value, implode('\", \"', array_keys(self::NUMBER_PADDING_ATTRIBUTES))));\n                }\n\n                $value = self::NUMBER_PADDING_ATTRIBUTES[$value];\n            }\n\n            $this->numberFormatters[$hash]->setAttribute(self::NUMBER_ATTRIBUTES[$name], $value);\n        }\n\n        foreach ($textAttrs as $name => $value) {\n            $this->numberFormatters[$hash]->setTextAttribute(self::NUMBER_TEXT_ATTRIBUTES[$name], $value);\n        }\n\n        foreach ($symbols as $name => $value) {\n            $this->numberFormatters[$hash]->setSymbol(self::NUMBER_SYMBOLS[$name], $value);\n        }\n\n        return $this->numberFormatters[$hash];\n    }","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/twigphp/Twig/blob/a414c3a491defb5a60f2fc88ef79ff37c90010cd/extra/intl-extra/IntlExtension.php#L571-L607","documentation":"When the attribute 'padding_position' is set in $attrs, its value is validated against IntlExtension::NUMBER_PADDING_ATTRIBUTES. An unknown padding position name throws this RuntimeError listing the valid positions.","triggerScenarios":"Calling format_number/format_currency with attrs={'padding_position': X} where X is not a key of NUMBER_PADDING_ATTRIBUTES — e.g. 'left'/'right' variants not in the accepted map, or a raw constant name like 'PAD_BEFORE_PREFIX'.","commonSituations":"Translating \\NumberFormatter::PAD_* constants directly to strings; typos in template arguments; config-driven padding settings not checked.","solutions":["Use one of the positions listed in the error (keys of NUMBER_PADDING_ATTRIBUTES, e.g. 'before_prefix', 'after_prefix', 'before_suffix', 'after_suffix')","Fix the padding position string in the attrs array","Validate configured padding positions against NUMBER_PADDING_ATTRIBUTES keys","Remove padding_position if padding is not required"],"exampleFix":"// before\n{{ n|format_number(attrs={'padding_position': 'before'}) }}\n// after\n{{ n|format_number(attrs={'padding_position': 'before_prefix'}) }}","handlingStrategy":"validation","validationCode":"if (isset($attrs['padding_position']) && !isset(IntlExtension::NUMBER_PADDING_ATTRIBUTES[$attrs['padding_position']])) { throw new \\InvalidArgumentException('Unknown padding position'); }","typeGuard":"function isKnownPaddingPosition(string $p): bool { return isset(IntlExtension::NUMBER_PADDING_ATTRIBUTES[$p]); }","tryCatchPattern":"try { $out = $intl->formatNumber($n, $style, $attrs); } catch (\\Twig\\Error\\RuntimeError $e) { if (str_contains($e->getMessage(), 'padding position')) { unset($attrs['padding_position']); $out = $intl->formatNumber($n, $style, $attrs); } else { throw $e; } }","preventionTips":["Use the documented padding position strings only","Validate padding config at startup","Avoid constructing padding position names from \\NumberFormatter constants"],"tags":["php","intl","number-formatting","padding"],"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"}