Skip to content

Commit b726eb3

Browse files
authored
Merge pull request #4554 from oleibman/deprecations
Eliminate Deprecated Constants
2 parents 7e89ad9 + 6d8fc67 commit b726eb3

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org). Thia is a
1010
### Breaking Changes
1111

1212
- Images will be loaded from an external source (e.g. http://example.com/img.png) only if the reader is explicitly set to allow it via `$reader->setAllowExternalImages(true)`. We do not believe that loading of external images is a widely used feature.
13+
- Deletion of items deprecated in Release 4. See "removed" below.
14+
- Move some properties from Base Reader to Html Reader. [PR #4551](https://github.com/PHPOffice/PhpSpreadsheet/pull/4551)
15+
- DefaultValueBinder will treat integers with more than 15 digits as strings. [Issue #4522](https://github.com/PHPOffice/PhpSpreadsheet/issues/4522) [PR #4527](https://github.com/PHPOffice/PhpSpreadsheet/pull/4527)
1316

1417
### Added
1518

1619
- Nothing yet.
1720

1821
### Removed
1922

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

2225
### Changed
2326

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)