Skip to content

Conversation

chalda-pnuzig
Copy link

Description

Previously, $title->getText() was assumed to always return a string, but in some cases, it returns a PhpOffice\PhpWord\Element\TextRun. This commit adds a check to determine if the returned value is a TextRun and properly extracts text from its child elements.

Fixes #1625

Previously, `$title->getText()` was assumed to always return a string, but in some cases, it returns a `PhpOffice\PhpWord\Element\TextRun`. This commit adds a check to determine if the returned value is a `TextRun` and properly extracts text from its child elements.
}
$this->writeText($uploadedText);
} else {
$this->writeText((is_string($titleText) ? $titleText : '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->writeText((is_string($titleText) ? $titleText : '');
$this->writeText(is_string($titleText) ? $titleText : '');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

TextRun in addTitle causes TOC error.
2 participants