{"record":{"id":"1e75a0af858e1c09","repo":"PHPOffice/PHPWord","slug":"invalid-value-on-of-implode-position-possible","errorCode":null,"errorMessage":"Invalid value, on of ' . implode(', ', $position) . ' possible","messagePattern":"Invalid value, on of ' \\. implode\\(', ', \\$position\\) \\. ' possible","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/PhpWord/ComplexType/FootnoteProperties.php","lineNumber":97,"sourceCode":"     * Set the Footnote Positioning Location (pageBottom, beneathText, sectEnd, docEnd).\n     *\n     * @param string $pos\n     *\n     * @return self\n     */\n    public function setPos($pos)\n    {\n        $position = [\n            self::POSITION_PAGE_BOTTOM,\n            self::POSITION_BENEATH_TEXT,\n            self::POSITION_SECTION_END,\n            self::POSITION_DOC_END,\n        ];\n\n        if (in_array($pos, $position)) {\n            $this->pos = $pos;\n        } else {\n            throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');\n        }\n\n        return $this;\n    }\n\n    /**\n     * Get the Footnote Numbering Format.\n     *\n     * @return string\n     */\n    public function getNumFmt()\n    {\n        return $this->numFmt;\n    }\n\n    /**\n     * Set the Footnote Numbering Format.\n     *","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/PHPOffice/PHPWord/blob/aef95c04151b5633cc505f672ddd6a71da900ee1/src/PhpWord/ComplexType/FootnoteProperties.php#L79-L115","documentation":"FootnoteProperties::setPos() validates the footnote position against a fixed whitelist (POSITION_PAGE, POSITION_SECTION, POSITION_DOC_END). If the passed value is not one of these class constants, an InvalidArgumentException is thrown listing the valid options. The message contains a typo ('on of' instead of 'one of') but the intent is clear: only the documented constants are accepted.","triggerScenarios":"Calling setPos() (directly or via FootnoteProperties constructor/style array, e.g. Section->addFootnote with footnoteProperties) with an arbitrary string like 'end' or 'document' instead of FootnoteProperties::POSITION_PAGE, POSITION_SECTION, or POSITION_DOC_END.","commonSituations":"Guessing the position string instead of using the class constants; copying XML attribute values from OOXML docs (e.g. 'docEnd' vs 'docEnd' casing variants) into the setter; typos in config arrays passed to style builders.","solutions":["Use one of the class constants: FootnoteProperties::POSITION_PAGE, POSITION_SECTION, or POSITION_DOC_END","Check spelling/casing of the value against the constants defined at the top of FootnoteProperties.php","Wrap the call in try-catch InvalidArgumentException if the value comes from user input, and fall back to the default"],"exampleFix":"// before\n$props->setPos('end');\n// after\n$props->setPos(FootnoteProperties::POSITION_DOC_END);","handlingStrategy":"validation","validationCode":"$allowed = [FootnoteProperties::POSITION_PAGE, FootnoteProperties::POSITION_SECTION, FootnoteProperties::POSITION_DOC_END];\nif (!in_array($pos, $allowed, true)) {\n    throw new UnexpectedValueException(\"pos must be one of: \" . implode(', ', $allowed));\n}","typeGuard":"function isValidFootnotePos(?string $pos): bool {\n    return in_array($pos, [FootnoteProperties::POSITION_PAGE, FootnoteProperties::POSITION_SECTION, FootnoteProperties::POSITION_DOC_END], true);\n}","tryCatchPattern":"try {\n    $props->setPos($pos);\n} catch (\\InvalidArgumentException $e) {\n    $props->setPos(FootnoteProperties::POSITION_PAGE); // safe default\n}","preventionTips":["Always use FootnoteProperties::POSITION_* constants, never raw strings","Pre-validate user/config input against the constant list","Write a unit test covering each allowed position value"],"tags":["php","phpword","invalid-argument","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"aef95c04151b5633cc505f672ddd6a71da900ee1","analyzedAt":"2026-09-14T10:53:58.933Z","contentChangedAt":"2026-09-14T10:53:58.933Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}