{"record":{"id":"122dfb73f6faa954","repo":"PHPOffice/PHPWord","slug":"invalid-value-on-of-implode-restartnumbers-possible","errorCode":null,"errorMessage":"Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible","messagePattern":"Invalid value, on of ' \\. implode\\(', ', \\$restartNumbers\\) \\. ' possible","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/PhpWord/ComplexType/FootnoteProperties.php","lineNumber":180,"sourceCode":"    /**\n     * Set the Footnote and Endnote Numbering Starting Value (continuous, eachSect, eachPage).\n     *\n     * @param  string $numRestart\n     *\n     * @return self\n     */\n    public function setNumRestart($numRestart)\n    {\n        $restartNumbers = [\n            self::RESTART_NUMBER_CONTINUOUS,\n            self::RESTART_NUMBER_EACH_SECTION,\n            self::RESTART_NUMBER_EACH_PAGE,\n        ];\n\n        if (in_array($numRestart, $restartNumbers)) {\n            $this->numRestart = $numRestart;\n        } else {\n            throw new InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');\n        }\n\n        return $this;\n    }\n}\n","sourceCodeStart":162,"sourceCodeEnd":186,"githubUrl":"https://github.com/PHPOffice/PHPWord/blob/aef95c04151b5633cc505f672ddd6a71da900ee1/src/PhpWord/ComplexType/FootnoteProperties.php#L162-L186","documentation":"FootnoteProperties::setNumRestart() validates the footnote numbering-restart mode against a whitelist (RESTART_NUMBER_CONTINUOUS, RESTART_NUMBER_EACH_PAGE, RESTART_NUMBER_EACH_SECTION). Any other value throws an InvalidArgumentException listing the valid constants. This guards the value written into the w:numRestart OOXML attribute.","triggerScenarios":"Calling setNumRestart() with an arbitrary string such as 'always' or 'page' instead of the class constants RESTART_NUMBER_CONTINUOUS, RESTART_NUMBER_EACH_PAGE, or RESTART_NUMBER_EACH_SECTION, whether directly or via a style/properties array.","commonSituations":"Translating OOXML numRestart attribute values with wrong casing; guessing the API instead of reading constants; reusing values from another library's footnote API.","solutions":["Use FootnoteProperties::RESTART_NUMBER_CONTINUOUS, RESTART_NUMBER_EACH_PAGE, or RESTART_NUMBER_EACH_SECTION","Compare your value against the RESTART_NUMBER_* constants at the top of FootnoteProperties.php","Validate user-supplied values against the constant list before calling the setter"],"exampleFix":"// before\n$props->setNumRestart('eachPage');\n// after\n$props->setNumRestart(FootnoteProperties::RESTART_NUMBER_EACH_PAGE);","handlingStrategy":"validation","validationCode":"$allowed = [FootnoteProperties::RESTART_NUMBER_CONTINUOUS, FootnoteProperties::RESTART_NUMBER_EACH_PAGE, FootnoteProperties::RESTART_NUMBER_EACH_SECTION];\nif (!in_array($numRestart, $allowed, true)) {\n    throw new UnexpectedValueException(\"numRestart must be one of: \" . implode(', ', $allowed));\n}","typeGuard":"function isValidNumRestart(?string $v): bool {\n    return in_array($v, [FootnoteProperties::RESTART_NUMBER_CONTINUOUS, FootnoteProperties::RESTART_NUMBER_EACH_PAGE, FootnoteProperties::RESTART_NUMBER_EACH_SECTION], true);\n}","tryCatchPattern":"try {\n    $props->setNumRestart($numRestart);\n} catch (\\InvalidArgumentException $e) {\n    $props->setNumRestart(FootnoteProperties::RESTART_NUMBER_CONTINUOUS);\n}","preventionTips":["Use the RESTART_NUMBER_* class constants only","Validate configuration values before constructing FootnoteProperties","Keep a constants-driven whitelist in your config layer"],"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"}