Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix text extraction from PhpWord TextRun elements #2757

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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