diff --git a/CHANGELOG.md b/CHANGELOG.md index 959648a02..1c21c2990 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,14 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Removed -- Nothing yet. +- Worksheet::getStyles - no replacement. [PR #4330](https://github.com/PHPOffice/PhpSpreadsheet/pull/4330) +- The following items were deprecated in release 3 and are now removed. +- Drawing::setIsUrl - no replacement. +- Settings::setLibXmlLoaderOptions() and Settings::getLibXmlLoaderOptions() - no replacement. +- Worksheet::getHashCode - no replacement. +- IReader::SKIP_EMPTY_CELLS - use its alias IGNORE_EMPTY_CELLS instead. +- Worksheet::getProtectedCells - use getProtectedCellRanges instead. +- Writer/Html::isMpdf property - use instanceof Mpdf instead. ### Changed diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 6075eef4f..250ef4f1c 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -18,11 +18,6 @@ interface IReader */ public const READ_DATA_ONLY = 2; - /** - * @deprecated 3.4.0 use IGNORE_EMPTY_CELLS instead. - */ - public const SKIP_EMPTY_CELLS = self::IGNORE_EMPTY_CELLS; - /** * Flag used to ignore empty cells when reading. * diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index c31a05dcb..5e4877372 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -321,14 +321,14 @@ class ReferenceHelper */ protected function adjustProtectedCells(Worksheet $worksheet, int $numberOfColumns, int $numberOfRows): void { - $aProtectedCells = $worksheet->getProtectedCells(); + $aProtectedCells = $worksheet->getProtectedCellRanges(); ($numberOfColumns > 0 || $numberOfRows > 0) ? uksort($aProtectedCells, [self::class, 'cellReverseSort']) : uksort($aProtectedCells, [self::class, 'cellSort']); - foreach ($aProtectedCells as $cellAddress => $value) { + foreach ($aProtectedCells as $cellAddress => $protectedRange) { $newReference = $this->updateCellReference($cellAddress); if ($cellAddress !== $newReference) { - $worksheet->protectCells($newReference, $value, true); + $worksheet->protectCells($newReference, $protectedRange->getPassword(), true); $worksheet->unprotectCells($cellAddress); } } diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index d32ef7c44..5f2308f76 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -20,11 +20,6 @@ class Settings */ private static ?string $chartRenderer = null; - /** - * Default options for libxml loader. - */ - private static ?int $libXmlLoaderOptions = null; - /** * The cache implementation to be used for cell collection. */ @@ -90,36 +85,6 @@ class Settings return ENT_COMPAT; } - /** - * Set default options for libxml loader. - * - * @param ?int $options Default options for libxml loader - * - * @deprecated 3.5.0 no longer needed - */ - public static function setLibXmlLoaderOptions(?int $options): int - { - if ($options === null) { - $options = defined('LIBXML_DTDLOAD') ? (LIBXML_DTDLOAD | LIBXML_DTDATTR) : 0; - } - self::$libXmlLoaderOptions = $options; - - return $options; - } - - /** - * Get default options for libxml loader. - * Defaults to LIBXML_DTDLOAD | LIBXML_DTDATTR when not set explicitly. - * - * @return int Default options for libxml loader - * - * @deprecated 3.5.0 no longer needed - */ - public static function getLibXmlLoaderOptions(): int - { - return self::$libXmlLoaderOptions ?? (defined('LIBXML_DTDLOAD') ? (LIBXML_DTDLOAD | LIBXML_DTDATTR) : 0); - } - /** * Sets the implementation of cache that should be used for cell collection. */ diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 5905d7f2f..09e32ff2f 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -192,20 +192,6 @@ class Drawing extends BaseDrawing return $this->isUrl; } - /** - * Set isURL. - * - * @return $this - * - * @deprecated 3.7.0 not needed, property is set by setPath - */ - public function setIsURL(bool $isUrl): self - { - $this->isUrl = $isUrl; - - return $this; - } - /** * Get hash code. * diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index c3f9da594..78d377d59 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1957,24 +1957,6 @@ class Worksheet return $this; } - /** - * Get password for protected cells. - * - * @return string[] - * - * @deprecated 2.0.1 use getProtectedCellRanges instead - * @see Worksheet::getProtectedCellRanges() - */ - public function getProtectedCells(): array - { - $array = []; - foreach ($this->protectedCells as $key => $protectedRange) { - $array[$key] = $protectedRange->getPassword(); - } - - return $array; - } - /** * Get protected cells. * @@ -3198,14 +3180,6 @@ class Worksheet return $this; } - /** - * @deprecated 3.5.0 use getHashInt instead. - */ - public function getHashCode(): string - { - return (string) $this->hash; - } - public function getHashInt(): int { return $this->hash; diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 2b1d0a474..2011bad18 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -118,13 +118,6 @@ class Html extends BaseWriter */ protected bool $isPdf = false; - /** - * Is the current writer creating mPDF? - * - * @deprecated 2.0.1 use instanceof Mpdf instead - */ - protected bool $isMPdf = false; - /** * Generate the Navigation block. */ diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index ca031b45e..a98e3ed9c 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -10,13 +10,6 @@ class Mpdf extends Pdf public const SIMULATED_BODY_START = ''; private const BODY_TAG = '
'; - /** - * Is the current writer creating mPDF? - * - * @deprecated 2.0.1 use instanceof Mpdf instead - */ - protected bool $isMPdf = true; - /** * Gets the implementation of external PDF library that should be used. * diff --git a/tests/PhpSpreadsheetTests/SettingsTest.php b/tests/PhpSpreadsheetTests/SettingsTest.php index b9be009ba..5a4d1518c 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -15,21 +15,6 @@ class SettingsTest extends TestCase Settings::setCache(null); } - public function testGetXMLSettings(): void - { - $result = Settings::getLibXmlLoaderOptions(); - self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR) & $result)); - } - - public function testSetXMLSettings(): void - { - $original = Settings::getLibXmlLoaderOptions(); - Settings::setLibXmlLoaderOptions(LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID); - $result = Settings::getLibXmlLoaderOptions(); - self::assertTrue((bool) ((LIBXML_DTDLOAD | LIBXML_DTDATTR | LIBXML_DTDVALID) & $result)); - Settings::setLibXmlLoaderOptions($original); - } - public function testInvalidChartRenderer(): void { $this->expectException(SpException::class); diff --git a/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php b/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php index bc2717804..642a7eac0 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php @@ -133,8 +133,6 @@ class ByColumnAndRowTest extends TestCase $sheet->fromArray($data, null, 'B2', true); $sheet->protectCells([2, 2, 3, 3], 'secret', false); - $protectedRanges = $sheet->/** @scrutinizer ignore-deprecated*/ getProtectedCells(); - self::assertArrayHasKey('B2:C3', $protectedRanges); $protectedRanges2 = $sheet->getProtectedCellRanges(); self::assertArrayHasKey('B2:C3', $protectedRanges2); $spreadsheet->disconnectWorksheets(); diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php index f31e6718c..c0de73c9e 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataTest.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Writer\Xlsx; use Exception; -use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Shared\File; use PHPUnit\Framework\TestCase; use ZipArchive; @@ -66,7 +65,7 @@ class UnparsedDataTest extends TestCase self::assertNotEmpty($resultVbaProjectRaw, 'vbaProject.bin not found!'); // xl/workbook.xml - $xmlWorkbook = simplexml_load_string($resultWorkbookRaw ?: '', 'SimpleXMLElement', Settings::getLibXmlLoaderOptions()); + $xmlWorkbook = simplexml_load_string($resultWorkbookRaw ?: '', 'SimpleXMLElement'); self::assertNotFalse($xmlWorkbook); if (!$xmlWorkbook->workbookProtection) { self::fail('workbook.xml/workbookProtection not found!'); @@ -88,7 +87,7 @@ class UnparsedDataTest extends TestCase // xl/worksheets/sheet1.xml self::assertStringContainsString('