Skip to content

Commit 85cfe10

Browse files
authored
Update Header.php - Fix binary operation error
At the point of errors, the variable must be an object because it passed the method_exists() test, but because the php static analysis tests didn't like the chance that it might return a string, let's explicitly cast the variable as an object.
1 parent dd9111c commit 85cfe10

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/PhpWord/Writer/RTF/Part/Header.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ private function registerFont(): void
202202
$this->registerBorderColor($section->getStyle());
203203
foreach ($elements as $element) {
204204
if (method_exists($element, 'getFontStyle')) {
205-
$style = $element->getFontStyle();
205+
$style = (object)$element->getFontStyle();
206206
$this->registerFontItems($style);
207207
} elseif (method_exists($element, 'getElements')) {
208-
$textRuns = $element->getElements();
209-
foreach ($textRuns as $textRun) {
210-
if (method_exists($textRun, 'getFontStyle')) {
211-
$style = $textRun->getFontStyle();
208+
$subElements = $element->getElements();
209+
foreach ($subElements as $subElement) {
210+
if (method_exists($subElement, 'getFontStyle')) {
211+
$style = (object)$subElement->getFontStyle();
212212
$this->registerFontItems($style);
213213
}
214214
}

0 commit comments

Comments
 (0)