Skip to content

Commit 728e2f0

Browse files
committed
Updated change log, fixed coding style issues and ensured that the style value is returned and not a clone.
1 parent eafb11e commit 728e2f0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docs/changes/1.x/1.4.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
- Writer ODText: Support for images inside a textRun by [@Progi1984](https://github.com/Progi1984) fixing [#2240](https://github.com/PHPOffice/PHPWord/issues/2240) in [#2668](https://github.com/PHPOffice/PHPWord/pull/2668)
1313
- Allow vAlign and vMerge on Style\Cell to be set to null by [@SpraxDev](https://github.com/SpraxDev) fixing [#2673](https://github.com/PHPOffice/PHPWord/issues/2673) in [#2676](https://github.com/PHPOffice/PHPWord/pull/2676)
14+
- Fixed that passed style objects to the constructor of elements were ignored like `\PhpOffice\PhpWord\Style\Cell` for `\PhpOffice\PhpWord\Element\Cell` by [@hazington](https://github.com/hazington)
1415

1516
### Miscellaneous
1617

src/PhpWord/Element/AbstractElement.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
use DateTime;
2121
use InvalidArgumentException;
22+
use function is_array;
2223
use PhpOffice\PhpWord\Collection\Comments;
2324
use PhpOffice\PhpWord\Media;
2425
use PhpOffice\PhpWord\PhpWord;
2526
use PhpOffice\PhpWord\Style;
26-
use PhpOffice\PhpWord\Style\AbstractStyle;
2727

28-
use function is_array;
28+
use PhpOffice\PhpWord\Style\AbstractStyle;
2929

3030
/**
3131
* Element abstract class.
@@ -485,19 +485,20 @@ public function isInSection()
485485
* Set new style value.
486486
*
487487
* @param AbstractStyle $styleObject Style object
488-
* @param null|string|array|AbstractStyle $styleValue Style value
488+
* @param null|AbstractStyle|array|string $styleValue Style value
489489
* @param bool $returnObject Always return object
490490
*
491-
* @return null|string|array|AbstractStyle
491+
* @return mixed
492492
*/
493493
protected function setNewStyle($styleObject, $styleValue = null, $returnObject = false)
494494
{
495495
if ($styleValue instanceof AbstractStyle && get_class($styleValue) === get_class($styleObject)) {
496-
return clone $styleValue;
496+
return $styleValue;
497497
}
498498

499499
if (is_array($styleValue)) {
500500
$styleObject->setStyleByArray($styleValue);
501+
501502
return $styleObject;
502503
}
503504

0 commit comments

Comments
 (0)