Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/PhpWord/Writer/Word2007/Element/TOC.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,17 @@
$xmlWriter->startElement('w:t');

$titleText = $title->getText();
$this->writeText(is_string($titleText) ? $titleText : '');
if (get_class($titleText) === 'PhpOffice\PhpWord\Element\TextRun') {
$textRunElements = $title->getText()->getElements();
$uploadedText = '';
foreach ($textRunElements as $textRunElement) {
$uploadedText .= $textRunElement->getText();
$uploadedText .= ' ';
}
$this->writeText($uploadedText);
} else {
$this->writeText((is_string($titleText) ? $titleText : '');

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.2)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.3)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.4)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.0)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.1)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.2)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.3)

Syntax error, unexpected ';', expecting ')' on line 108

Check failure on line 108 in src/PhpWord/Writer/Word2007/Element/TOC.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.4)

Syntax error, unexpected ';', expecting ')' on line 108
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 : '');

}

$xmlWriter->endElement(); // w:t
$xmlWriter->endElement(); // w:r
Expand Down
Loading