Skip to content

Commit 573f1c3

Browse files
committed
set default value on empty value attribute
1 parent 0af4ca1 commit 573f1c3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/PhpWord/Reader/Word2007/AbstractPart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ protected function readStyleDefs(XMLReader $xmlReader, ?DOMElement $parentNode =
626626
$styles = [];
627627

628628
foreach ($styleDefs as $styleProp => $styleVal) {
629-
[$method, $element, $attribute, $expected] = array_pad($styleVal, 4, null);
629+
[$method, $element, $attribute, $expected, $default] = array_pad($styleVal, 5, null);
630630

631631
$element = $this->findPossibleElement($xmlReader, $parentNode, $element);
632632
if ($element === null) {
@@ -640,7 +640,7 @@ protected function readStyleDefs(XMLReader $xmlReader, ?DOMElement $parentNode =
640640

641641
// Use w:val as default if no attribute assigned
642642
$attribute = ($attribute === null) ? 'w:val' : $attribute;
643-
$attributeValue = $xmlReader->getAttribute($attribute, $node);
643+
$attributeValue = $xmlReader->getAttribute($attribute, $node) ?? $default;
644644

645645
$styleValue = $this->readStyleDef($method, $attributeValue, $expected);
646646
if ($styleValue !== null) {

0 commit comments

Comments
 (0)