PHPOffice/PHPWord · error · PhpOffice\PhpWord\Exception\Exception
Invalid parameters passed.
Error message
Invalid parameters passed.
What it means
Validation guard in Rels::writeRel: relationship entries are only written when both $type and $target are non-empty; a caller (writeRels/writeMediaRel) passed an incomplete relationship (empty type or target) so the parameters are considered invalid.
Solutions
- Ensure every relationship added to Rels supplies a non-empty type and target.
- Check custom code or hooks that call addRelationship/writeRels with incomplete arguments.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/PhpWord/Writer/Word2007/Part/Rels.php:123 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of PHPOffice/PHPWord@aef95c0415 (2026-09-14).
Data as JSON: /api/errors/afb360e5c7cebc9f.
Report an issue: GitHub.
Appendix: source
Thrown at src/PhpWord/Writer/Word2007/Part/Rels.php:123
* @param string $target Relationship target
* @param string $targetMode Relationship target mode
*/
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = ''): void
{
if ($type != '' && $target != '') {
if (strpos($relId, 'rId') === false) {
$relId = 'rId' . $relId;
}
$xmlWriter->startElement('Relationship');
$xmlWriter->writeAttribute('Id', $relId);
$xmlWriter->writeAttribute('Type', 'http://schemas.openxmlformats.org/' . $type);
$xmlWriter->writeAttribute('Target', $target);
if ($targetMode != '') {
$xmlWriter->writeAttribute('TargetMode', $targetMode);
}
$xmlWriter->endElement();
} else {
throw new Exception('Invalid parameters passed.');
}
}
}
View on GitHub (pinned to aef95c0415)