diff --git a/src/Spout/Common/Entity/Style/Style.php b/src/Spout/Common/Entity/Style/Style.php index f4beb97..2bacc7a 100644 --- a/src/Spout/Common/Entity/Style/Style.php +++ b/src/Spout/Common/Entity/Style/Style.php @@ -490,13 +490,13 @@ class Style return $this->isRegistered; } - public function register(int $id) : void + public function markAsRegistered(?int $id) : void { $this->setId($id); $this->isRegistered = true; } - public function unregister() : void + public function unmarkAsRegistered() : void { $this->setId(0); $this->isRegistered = false; diff --git a/src/Spout/Writer/Common/Manager/Style/StyleManagerInterface.php b/src/Spout/Writer/Common/Manager/Style/StyleManagerInterface.php index be77110..6d01bd5 100644 --- a/src/Spout/Writer/Common/Manager/Style/StyleManagerInterface.php +++ b/src/Spout/Writer/Common/Manager/Style/StyleManagerInterface.php @@ -24,7 +24,7 @@ interface StyleManagerInterface * Typically, set "wrap text" if a cell contains a new line. * * @param Cell $cell - * @return ManagedStyle|null The eventually updated style + * @return ManagedStyle The eventually updated style */ public function applyExtraStylesIfNeeded(Cell $cell) : ManagedStyle; } diff --git a/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php b/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php index dcfa267..6b439a7 100644 --- a/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php +++ b/src/Spout/Writer/Common/Manager/Style/StyleRegistry.php @@ -38,7 +38,7 @@ class StyleRegistry if (!$this->hasSerializedStyleAlreadyBeenRegistered($serializedStyle)) { $nextStyleId = \count($this->serializedStyleToStyleIdMappingTable); - $style->register($nextStyleId); + $style->markAsRegistered($nextStyleId); $this->serializedStyleToStyleIdMappingTable[$serializedStyle] = $nextStyleId; $this->styleIdToStyleMappingTable[$nextStyleId] = $style; @@ -47,19 +47,6 @@ class StyleRegistry return $this->getStyleFromSerializedStyle($serializedStyle); } - /** - * Returns whether the given style has already been registered. - * - * @param Style $style - * @return bool - */ - protected function hasStyleAlreadyBeenRegistered(Style $style) - { - $serializedStyle = $this->serialize($style); - - return $this->hasSerializedStyleAlreadyBeenRegistered($serializedStyle); - } - /** * Returns whether the serialized style has already been registered. * @@ -114,11 +101,11 @@ class StyleRegistry { // In order to be able to properly compare style, set static ID value and reset registration $currentId = $style->getId(); - $style->unregister(); + $style->unmarkAsRegistered(); $serializedStyle = \serialize($style); - $style->setId($currentId); + $style->markAsRegistered($currentId); return $serializedStyle; } diff --git a/src/Spout/Writer/ODS/Manager/WorksheetManager.php b/src/Spout/Writer/ODS/Manager/WorksheetManager.php index 894c82f..1997e9e 100644 --- a/src/Spout/Writer/ODS/Manager/WorksheetManager.php +++ b/src/Spout/Writer/ODS/Manager/WorksheetManager.php @@ -165,7 +165,8 @@ class WorksheetManager implements WorksheetManagerInterface if ($managedStyle->isUpdated()) { $registeredStyle = $this->styleManager->registerStyle($managedStyle->getStyle()); } else { - $registeredStyle = $rowStyle = $this->styleManager->registerStyle($rowStyle); + $registeredStyle = $this->styleManager->registerStyle($rowStyle); + $rowStyle = $registeredStyle; } } else { $mergedCellAndRowStyle = $this->styleMerger->merge($cell->getStyle(), $rowStyle); diff --git a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php index d68d8f3..3a210d6 100644 --- a/src/Spout/Writer/XLSX/Manager/WorksheetManager.php +++ b/src/Spout/Writer/XLSX/Manager/WorksheetManager.php @@ -193,7 +193,8 @@ EOD; if ($managedStyle->isUpdated()) { $registeredStyle = $this->styleManager->registerStyle($managedStyle->getStyle()); } else { - $registeredStyle = $rowStyle = $this->styleManager->registerStyle($rowStyle); + $registeredStyle = $this->styleManager->registerStyle($rowStyle); + $rowStyle = $registeredStyle; } } else { $mergedCellAndRowStyle = $this->styleMerger->merge($cell->getStyle(), $rowStyle);