Skip to content

Commit a12a0d0

Browse files
committed
Eliminate Deprecated Constants
In Theme, change COLOR_SCHEME_2013_PLUS_NAME to private (use COLOR_SCHEME_2013_2022_NAME instead), and delete COLOR_SCHEME_2013_PLUS (use COLOR_SCHEME_2013_2022).
1 parent 7d1562a commit a12a0d0

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org).
99

1010
### Breaking Changes
1111

12-
- Nothing yet.
12+
- Deletion of items deprecated in Release 4. See "removed" below.
1313

1414
### Added
1515

1616
- Nothing yet.
1717

1818
### Removed
1919

20-
- Nothing yet.
20+
- Theme public constants COLOR_SCHEME_2013_PLUS_NAME (use COLOR_SCHEME_2013_2022_NAME) and COLOR_SCHEME_2013_PLUS (use COLOR_SCHEME_2013_2022).
2121

2222
### Changed
2323

src/PhpSpreadsheet/Theme.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ class Theme
2424
'hlink' => '0563C1',
2525
'folHlink' => '954F72',
2626
];
27-
/** @deprecated 4.4.0 Use COLOR_SCHEME_2013_2022_NAME */
28-
public const COLOR_SCHEME_2013_PLUS_NAME = 'Office 2013+';
29-
/** @deprecated 4.4.0 Use COLOR_SCHEME_2013_2022 */
30-
public const COLOR_SCHEME_2013_PLUS = self::COLOR_SCHEME_2013_2022;
27+
private const COLOR_SCHEME_2013_PLUS_NAME = 'Office 2013+';
3128

3229
public const COLOR_SCHEME_2007_2010_NAME = 'Office 2007-2010';
3330
public const COLOR_SCHEME_2007_2010 = [
@@ -177,16 +174,16 @@ public function getThemeColorName(): string
177174
/** @param null|string[] $themeColors */
178175
public function setThemeColorName(string $name, ?array $themeColors = null, ?Spreadsheet $spreadsheet = null): self
179176
{
177+
if ($name === self::COLOR_SCHEME_2013_PLUS_NAME) {
178+
// Ensure against this value being found in
179+
// spreadsheets created while constant was public.
180+
$name = self::COLOR_SCHEME_2013_2022_NAME;
181+
}
180182
$this->themeColorName = $name;
181183
if ($name === self::COLOR_SCHEME_2007_2010_NAME) {
182184
$themeColors = $themeColors ?? self::COLOR_SCHEME_2007_2010;
183185
$this->majorFontLatin = 'Cambria';
184186
$this->minorFontLatin = 'Calibri';
185-
} elseif ($name === self::COLOR_SCHEME_2013_PLUS_NAME) { //* @phpstan-ignore-line
186-
// delete this block when deprecated constants removed
187-
$themeColors = $themeColors ?? self::COLOR_SCHEME_2013_PLUS; //* @phpstan-ignore-line
188-
$this->majorFontLatin = 'Calibri Light';
189-
$this->minorFontLatin = 'Calibri';
190187
} elseif ($name === self::COLOR_SCHEME_2013_2022_NAME) {
191188
$themeColors = $themeColors ?? self::COLOR_SCHEME_2013_2022;
192189
$this->majorFontLatin = 'Calibri Light';

tests/PhpSpreadsheetTests/Writer/Xlsx/ThemeColorsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212

1313
class ThemeColorsTest extends AbstractFunctional
1414
{
15+
private const COLOR_SCHEME_2013_PLUS_NAME = 'Office 2013+';
16+
1517
public function testOffice2013Theme(): void
1618
{
1719
$spreadsheet = new Spreadsheet();
1820
$spreadsheet->getTheme()
1921
->setThemeColorName(
20-
SpreadsheetTheme::COLOR_SCHEME_2013_PLUS_NAME //* @phpstan-ignore-line
22+
self::COLOR_SCHEME_2013_PLUS_NAME
2123
);
2224
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
2325
$spreadsheet->disconnectWorksheets();
2426
self::assertSame(
25-
SpreadsheetTheme::COLOR_SCHEME_2013_PLUS_NAME, //* @phpstan-ignore-line
27+
SpreadsheetTheme::COLOR_SCHEME_2013_2022_NAME,
2628
$reloadedSpreadsheet->getTheme()->getThemeColorName()
2729
);
2830
self::assertSame('FFC000', $reloadedSpreadsheet->getTheme()->getThemeColors()['accent4']);

0 commit comments

Comments
 (0)