From 816596183fbcf7dd7dd158630b15b7e0620d7f4b Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Tue, 29 Dec 2020 09:18:59 +1300 Subject: [PATCH 1/4] Add full support for PHP 8.0 Unfortunately due to PHPUnit 8.5 dependency this also drops support for PHP 7.1 --- .gitignore | 1 + .travis.yml | 8 ++++---- README.md | 2 +- UPGRADE-3.0.md | 2 +- composer.json | 6 +++--- docs/_pages/getting-started.md | 2 +- phpunit.xml | 2 +- tests/Spout/Common/Entity/RowTest.php | 2 +- tests/Spout/Common/Helper/FileSystemHelperTest.php | 2 +- tests/Spout/Common/Manager/OptionsManagerTest.php | 2 +- tests/Spout/Reader/ODS/ReaderTest.php | 8 ++++++++ .../Reader/XLSX/Manager/SharedStringsManagerTest.php | 4 ++-- tests/Spout/Reader/XLSX/ReaderTest.php | 4 ++++ tests/Spout/Writer/CSV/WriterTest.php | 4 ++-- tests/Spout/Writer/Common/Entity/SheetTest.php | 2 +- .../Spout/Writer/Common/Manager/Style/StyleMergerTest.php | 2 +- .../Writer/Common/Manager/Style/StyleRegistryTest.php | 2 +- tests/Spout/Writer/ODS/SheetTest.php | 4 ++-- tests/Spout/Writer/ODS/WriterTest.php | 6 +++--- tests/Spout/Writer/ODS/WriterWithStyleTest.php | 2 +- tests/Spout/Writer/XLSX/SheetTest.php | 4 ++-- tests/Spout/Writer/XLSX/WriterTest.php | 6 +++--- tests/Spout/Writer/XLSX/WriterWithStyleTest.php | 2 +- 23 files changed, 46 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 048320b..6253664 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /vendor /composer.lock /.php_cs.cache +/.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index ac931ed..9babd77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,16 +5,16 @@ language: php matrix: include: - - php: 7.1 - env: WITH_CS=true - - php: 7.1 - env: WITH_PHPUNIT=true WITH_COVERAGE=true - php: 7.2 env: WITH_PHPUNIT=true - php: 7.3 env: WITH_PHPUNIT=true + - php: 7.3 + env: WITH_PHPUNIT=true WITH_COVERAGE=true - php: 7.4 env: WITH_PHPUNIT=true + - php: 8.0 + env: WITH_PHPUNIT=true cache: diff --git a/README.md b/README.md index 517f5a4..a9a0a9c 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Full documentation can be found at [https://opensource.box.com/spout/](https://o ## Requirements -* PHP version 7.1 or higher +* PHP version 7.2 or higher * PHP extension `php_zip` enabled * PHP extension `php_xmlreader` enabled diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md index 3952443..9b2e370 100644 --- a/UPGRADE-3.0.md +++ b/UPGRADE-3.0.md @@ -11,7 +11,7 @@ With the 3.0 version, this is now possible: each cell can have its own style. Spout 3.0 tries to enforce better typing. For instance, instead of using/returning generic arrays, Spout now makes use of specific `Row` and `Cell` objects that can encapsulate more data such as type, style, value. -Finally, **_Spout 3.0 only supports PHP 7.1 and above_**, as other PHP versions are no longer supported by the community. +Finally, **_Spout 3.2 only supports PHP 7.2 and above_**, as other PHP versions are no longer supported by the community. Reader changes -------------- diff --git a/composer.json b/composer.json index 8943469..4d9642b 100644 --- a/composer.json +++ b/composer.json @@ -12,12 +12,12 @@ } ], "require": { - "php": ">=7.1.0", + "php": ">=7.2.0", "ext-zip": "*", "ext-xmlreader" : "*" }, "require-dev": { - "phpunit/phpunit": "^7", + "phpunit/phpunit": "^8", "friendsofphp/php-cs-fixer": "^2" }, "suggest": { @@ -36,7 +36,7 @@ }, "config": { "platform": { - "php": "7.1" + "php": "7.2" } } } diff --git a/docs/_pages/getting-started.md b/docs/_pages/getting-started.md index 0004d4d..0e0b336 100755 --- a/docs/_pages/getting-started.md +++ b/docs/_pages/getting-started.md @@ -10,7 +10,7 @@ This guide will help you install {{ site.spout_html }} and teach you how to use ## Requirements -* PHP version 7.1 or higher +* PHP version 7.2 or higher * PHP extension `ext-zip` enabled * PHP extension `ext-xmlreader` enabled diff --git a/phpunit.xml b/phpunit.xml index 4c56189..4e410e2 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ setStyle($this->getStyleMock()) ->setCells([]); - $this->assertInternalType('object', $row); + $this->assertInstanceOf(Row::class, $row); } } diff --git a/tests/Spout/Common/Helper/FileSystemHelperTest.php b/tests/Spout/Common/Helper/FileSystemHelperTest.php index f99ab30..7eb0183 100644 --- a/tests/Spout/Common/Helper/FileSystemHelperTest.php +++ b/tests/Spout/Common/Helper/FileSystemHelperTest.php @@ -16,7 +16,7 @@ class FileSystemHelperTest extends TestCase /** * @return void */ - public function setUp() + public function setUp() : void { $baseFolder = \sys_get_temp_dir(); $this->fileSystemHelper = new FileSystemHelper($baseFolder); diff --git a/tests/Spout/Common/Manager/OptionsManagerTest.php b/tests/Spout/Common/Manager/OptionsManagerTest.php index e2f0c5c..b1cac58 100644 --- a/tests/Spout/Common/Manager/OptionsManagerTest.php +++ b/tests/Spout/Common/Manager/OptionsManagerTest.php @@ -14,7 +14,7 @@ class OptionsManagerTest extends TestCase */ protected $optionsManager; - protected function setUp() + protected function setUp(): void { $this->optionsManager = new class() extends OptionsManagerAbstract { protected function getSupportedOptions() diff --git a/tests/Spout/Reader/ODS/ReaderTest.php b/tests/Spout/Reader/ODS/ReaderTest.php index ce56e4b..cd30ae5 100644 --- a/tests/Spout/Reader/ODS/ReaderTest.php +++ b/tests/Spout/Reader/ODS/ReaderTest.php @@ -295,6 +295,10 @@ class ReaderTest extends TestCase */ public function testReadShouldBeProtectedAgainstBillionLaughsAttack() { + if (function_exists('xdebug_code_coverage_started') && xdebug_code_coverage_started()) { + $this->markTestSkipped('test not compatible with code coverage'); + } + $startTime = microtime(true); $fileName = 'attack_billion_laughs.ods'; @@ -318,6 +322,10 @@ class ReaderTest extends TestCase */ public function testReadShouldBeProtectedAgainstQuadraticBlowupAttack() { + if (function_exists('xdebug_code_coverage_started') && xdebug_code_coverage_started()) { + $this->markTestSkipped('test not compatible with code coverage'); + } + $startTime = microtime(true); $fileName = 'attack_quadratic_blowup.ods'; diff --git a/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php b/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php index 2f85f34..22df444 100644 --- a/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php +++ b/tests/Spout/Reader/XLSX/Manager/SharedStringsManagerTest.php @@ -25,7 +25,7 @@ class SharedStringsManagerTest extends TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->sharedStringsManager = null; } @@ -33,7 +33,7 @@ class SharedStringsManagerTest extends TestCase /** * @return void */ - public function tearDown() + public function tearDown(): void { if ($this->sharedStringsManager !== null) { $this->sharedStringsManager->cleanup(); diff --git a/tests/Spout/Reader/XLSX/ReaderTest.php b/tests/Spout/Reader/XLSX/ReaderTest.php index 51a7b0e..7d30f97 100644 --- a/tests/Spout/Reader/XLSX/ReaderTest.php +++ b/tests/Spout/Reader/XLSX/ReaderTest.php @@ -539,6 +539,10 @@ class ReaderTest extends TestCase */ public function testReadShouldBeProtectedAgainstQuadraticBlowupAttack() { + if (function_exists('xdebug_code_coverage_started') && xdebug_code_coverage_started()) { + $this->markTestSkipped('test not compatible with code coverage'); + } + $startTime = microtime(true); $this->getAllRowsForFile('attack_quadratic_blowup.xlsx'); diff --git a/tests/Spout/Writer/CSV/WriterTest.php b/tests/Spout/Writer/CSV/WriterTest.php index 0b3b238..deb3f22 100644 --- a/tests/Spout/Writer/CSV/WriterTest.php +++ b/tests/Spout/Writer/CSV/WriterTest.php @@ -101,7 +101,7 @@ class WriterTest extends TestCase ]); $writtenContent = $this->writeToCsvFileAndReturnWrittenContent($allRows, 'csv_with_utf8_bom.csv'); - $this->assertContains(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should contain a UTF-8 BOM'); + $this->assertStringStartsWith(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should contain a UTF-8 BOM'); } /** @@ -114,7 +114,7 @@ class WriterTest extends TestCase ]); $writtenContent = $this->writeToCsvFileAndReturnWrittenContent($allRows, 'csv_no_bom.csv', ',', '"', false); - $this->assertNotContains(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should not contain a UTF-8 BOM'); + $this->assertStringNotContainsString(EncodingHelper::BOM_UTF8, $writtenContent, 'The CSV file should not contain a UTF-8 BOM'); } /** diff --git a/tests/Spout/Writer/Common/Entity/SheetTest.php b/tests/Spout/Writer/Common/Entity/SheetTest.php index cb19d6f..3c50734 100644 --- a/tests/Spout/Writer/Common/Entity/SheetTest.php +++ b/tests/Spout/Writer/Common/Entity/SheetTest.php @@ -18,7 +18,7 @@ class SheetTest extends TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->sheetManager = new SheetManager(new StringHelper()); } diff --git a/tests/Spout/Writer/Common/Manager/Style/StyleMergerTest.php b/tests/Spout/Writer/Common/Manager/Style/StyleMergerTest.php index 46820c0..a91d13f 100644 --- a/tests/Spout/Writer/Common/Manager/Style/StyleMergerTest.php +++ b/tests/Spout/Writer/Common/Manager/Style/StyleMergerTest.php @@ -18,7 +18,7 @@ class StyleMergerTest extends TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->styleMerger = new StyleMerger(); } diff --git a/tests/Spout/Writer/Common/Manager/Style/StyleRegistryTest.php b/tests/Spout/Writer/Common/Manager/Style/StyleRegistryTest.php index 41cc571..20a764c 100644 --- a/tests/Spout/Writer/Common/Manager/Style/StyleRegistryTest.php +++ b/tests/Spout/Writer/Common/Manager/Style/StyleRegistryTest.php @@ -20,7 +20,7 @@ class StyleRegistryTest extends TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->defaultStyle = (new StyleBuilder())->build(); $this->styleRegistry = new StyleRegistry($this->defaultStyle); diff --git a/tests/Spout/Writer/ODS/SheetTest.php b/tests/Spout/Writer/ODS/SheetTest.php index a964a59..3bd2193 100644 --- a/tests/Spout/Writer/ODS/SheetTest.php +++ b/tests/Spout/Writer/ODS/SheetTest.php @@ -89,7 +89,7 @@ class SheetTest extends TestCase $pathToContentFile = $resourcePath . '#content.xml'; $xmlContents = file_get_contents('zip://' . $pathToContentFile); - $this->assertContains(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"'); + $this->assertStringContainsString(' table:display="false"', $xmlContents, 'The sheet visibility should have been changed to "hidden"'); } /** @@ -164,6 +164,6 @@ class SheetTest extends TestCase $pathToWorkbookFile = $resourcePath . '#content.xml'; $xmlContents = file_get_contents('zip://' . $pathToWorkbookFile); - $this->assertContains("table:name=\"$expectedName\"", $xmlContents, $message); + $this->assertStringContainsString("table:name=\"$expectedName\"", $xmlContents, $message); } } diff --git a/tests/Spout/Writer/ODS/WriterTest.php b/tests/Spout/Writer/ODS/WriterTest.php index b30a8f6..31dcccf 100644 --- a/tests/Spout/Writer/ODS/WriterTest.php +++ b/tests/Spout/Writer/ODS/WriterTest.php @@ -547,7 +547,7 @@ class WriterTest extends TestCase $pathToContentFile = $resourcePath . '#content.xml'; $xmlContents = file_get_contents('zip://' . $pathToContentFile); - $this->assertContains($value, $xmlContents, $message); + $this->assertStringContainsString($value, $xmlContents, $message); } /** @@ -562,7 +562,7 @@ class WriterTest extends TestCase $sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex); $valueAsXmlString = "$value"; - $this->assertContains($valueAsXmlString, $sheetXmlAsString, $message); + $this->assertStringContainsString($valueAsXmlString, $sheetXmlAsString, $message); } /** @@ -577,7 +577,7 @@ class WriterTest extends TestCase $sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex); $valueAsXmlString = "$value"; - $this->assertNotContains($valueAsXmlString, $sheetXmlAsString, $message); + $this->assertStringNotContainsString($valueAsXmlString, $sheetXmlAsString, $message); } /** diff --git a/tests/Spout/Writer/ODS/WriterWithStyleTest.php b/tests/Spout/Writer/ODS/WriterWithStyleTest.php index dcdd364..669d438 100644 --- a/tests/Spout/Writer/ODS/WriterWithStyleTest.php +++ b/tests/Spout/Writer/ODS/WriterWithStyleTest.php @@ -30,7 +30,7 @@ class WriterWithStyleTest extends TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->defaultStyle = (new StyleBuilder())->build(); } diff --git a/tests/Spout/Writer/XLSX/SheetTest.php b/tests/Spout/Writer/XLSX/SheetTest.php index cebd72e..a243161 100644 --- a/tests/Spout/Writer/XLSX/SheetTest.php +++ b/tests/Spout/Writer/XLSX/SheetTest.php @@ -89,7 +89,7 @@ class SheetTest extends TestCase $pathToWorkbookFile = $resourcePath . '#xl/workbook.xml'; $xmlContents = file_get_contents('zip://' . $pathToWorkbookFile); - $this->assertContains(' state="hidden"', $xmlContents, 'The sheet visibility should have been changed to "hidden"'); + $this->assertStringContainsString(' state="hidden"', $xmlContents, 'The sheet visibility should have been changed to "hidden"'); } /** @@ -166,6 +166,6 @@ class SheetTest extends TestCase $pathToWorkbookFile = $resourcePath . '#xl/workbook.xml'; $xmlContents = file_get_contents('zip://' . $pathToWorkbookFile); - $this->assertContains("assertStringContainsString("assertContains((string) $inlineData, $xmlContents, $message); + $this->assertStringContainsString((string) $inlineData, $xmlContents, $message); } /** @@ -624,7 +624,7 @@ class WriterTest extends TestCase $pathToSheetFile = $resourcePath . '#xl/worksheets/sheet' . $sheetIndex . '.xml'; $xmlContents = file_get_contents('zip://' . $pathToSheetFile); - $this->assertNotContains((string) $inlineData, $xmlContents, $message); + $this->assertStringNotContainsString((string) $inlineData, $xmlContents, $message); } /** @@ -639,6 +639,6 @@ class WriterTest extends TestCase $pathToSharedStringsFile = $resourcePath . '#xl/sharedStrings.xml'; $xmlContents = file_get_contents('zip://' . $pathToSharedStringsFile); - $this->assertContains($sharedString, $xmlContents, $message); + $this->assertStringContainsString($sharedString, $xmlContents, $message); } } diff --git a/tests/Spout/Writer/XLSX/WriterWithStyleTest.php b/tests/Spout/Writer/XLSX/WriterWithStyleTest.php index da0aec2..da063e8 100644 --- a/tests/Spout/Writer/XLSX/WriterWithStyleTest.php +++ b/tests/Spout/Writer/XLSX/WriterWithStyleTest.php @@ -32,7 +32,7 @@ class WriterWithStyleTest extends TestCase /** * @return void */ - public function setUp() + public function setUp(): void { $this->defaultStyle = (new StyleBuilder())->build(); } From c29d1877b8a5aef44c3a39930aa5b800db7cb35f Mon Sep 17 00:00:00 2001 From: jmsche Date: Fri, 29 May 2020 11:42:25 +0200 Subject: [PATCH 2/4] Fixed code style (probably due to recent php-cs-fixer version) --- src/Spout/Reader/ODS/SheetIterator.php | 4 ++-- src/Spout/Reader/XLSX/Manager/SharedStringsManager.php | 2 +- src/Spout/Reader/XLSX/RowIterator.php | 2 +- src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php | 2 +- src/Spout/Writer/ODS/Creator/ManagerFactory.php | 2 +- src/Spout/Writer/WriterAbstract.php | 2 +- src/Spout/Writer/XLSX/Creator/ManagerFactory.php | 2 +- tests/Spout/Reader/CSV/SpoutTestStream.php | 4 ++-- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Spout/Reader/ODS/SheetIterator.php b/src/Spout/Reader/ODS/SheetIterator.php index f35b852..c7b8cd9 100644 --- a/src/Spout/Reader/ODS/SheetIterator.php +++ b/src/Spout/Reader/ODS/SheetIterator.php @@ -28,13 +28,13 @@ class SheetIterator implements IteratorInterface const XML_ATTRIBUTE_TABLE_STYLE_NAME = 'table:style-name'; const XML_ATTRIBUTE_TABLE_DISPLAY = 'table:display'; - /** @var string $filePath Path of the file to be read */ + /** @var string Path of the file to be read */ protected $filePath; /** @var \Box\Spout\Common\Manager\OptionsManagerInterface Reader's options manager */ protected $optionsManager; - /** @var InternalEntityFactory $entityFactory Factory to create entities */ + /** @var InternalEntityFactory Factory to create entities */ protected $entityFactory; /** @var XMLReader The XMLReader object that will help read sheet's XML data */ diff --git a/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php b/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php index caaeed7..8850a69 100644 --- a/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php +++ b/src/Spout/Reader/XLSX/Manager/SharedStringsManager.php @@ -43,7 +43,7 @@ class SharedStringsManager /** @var InternalEntityFactory Factory to create entities */ protected $entityFactory; - /** @var HelperFactory $helperFactory Factory to create helpers */ + /** @var HelperFactory Factory to create helpers */ protected $helperFactory; /** @var CachingStrategyFactory Factory to create shared strings caching strategies */ diff --git a/src/Spout/Reader/XLSX/RowIterator.php b/src/Spout/Reader/XLSX/RowIterator.php index 4af4530..a54b8b1 100644 --- a/src/Spout/Reader/XLSX/RowIterator.php +++ b/src/Spout/Reader/XLSX/RowIterator.php @@ -35,7 +35,7 @@ class RowIterator implements IteratorInterface /** @var string Path of the XLSX file being read */ protected $filePath; - /** @var string $sheetDataXMLFilePath Path of the sheet data XML file as in [Content_Types].xml */ + /** @var string Path of the sheet data XML file as in [Content_Types].xml */ protected $sheetDataXMLFilePath; /** @var \Box\Spout\Reader\Wrapper\XMLReader The XMLReader object that will help read sheet's XML data */ diff --git a/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php b/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php index b513555..653778c 100644 --- a/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php +++ b/src/Spout/Writer/Common/Manager/WorkbookManagerAbstract.php @@ -44,7 +44,7 @@ abstract class WorkbookManagerAbstract implements WorkbookManagerInterface /** @var InternalEntityFactory Factory to create entities */ protected $entityFactory; - /** @var ManagerFactoryInterface $managerFactory Factory to create managers */ + /** @var ManagerFactoryInterface Factory to create managers */ protected $managerFactory; /** @var Worksheet The worksheet where data will be written to */ diff --git a/src/Spout/Writer/ODS/Creator/ManagerFactory.php b/src/Spout/Writer/ODS/Creator/ManagerFactory.php index f38c500..a5b77ee 100644 --- a/src/Spout/Writer/ODS/Creator/ManagerFactory.php +++ b/src/Spout/Writer/ODS/Creator/ManagerFactory.php @@ -22,7 +22,7 @@ class ManagerFactory implements ManagerFactoryInterface /** @var InternalEntityFactory */ protected $entityFactory; - /** @var HelperFactory $helperFactory */ + /** @var HelperFactory */ protected $helperFactory; /** diff --git a/src/Spout/Writer/WriterAbstract.php b/src/Spout/Writer/WriterAbstract.php index d96a628..bbaa735 100644 --- a/src/Spout/Writer/WriterAbstract.php +++ b/src/Spout/Writer/WriterAbstract.php @@ -33,7 +33,7 @@ abstract class WriterAbstract implements WriterInterface /** @var GlobalFunctionsHelper Helper to work with global functions */ protected $globalFunctionsHelper; - /** @var HelperFactory $helperFactory */ + /** @var HelperFactory */ protected $helperFactory; /** @var OptionsManagerInterface Writer options manager */ diff --git a/src/Spout/Writer/XLSX/Creator/ManagerFactory.php b/src/Spout/Writer/XLSX/Creator/ManagerFactory.php index f27a2f2..aa3bcd5 100644 --- a/src/Spout/Writer/XLSX/Creator/ManagerFactory.php +++ b/src/Spout/Writer/XLSX/Creator/ManagerFactory.php @@ -24,7 +24,7 @@ class ManagerFactory implements ManagerFactoryInterface /** @var InternalEntityFactory */ protected $entityFactory; - /** @var HelperFactory $helperFactory */ + /** @var HelperFactory */ protected $helperFactory; /** diff --git a/tests/Spout/Reader/CSV/SpoutTestStream.php b/tests/Spout/Reader/CSV/SpoutTestStream.php index 3bfd06e..d66e811 100644 --- a/tests/Spout/Reader/CSV/SpoutTestStream.php +++ b/tests/Spout/Reader/CSV/SpoutTestStream.php @@ -14,10 +14,10 @@ class SpoutTestStream const PATH_TO_CSV_RESOURCES = 'tests/resources/csv/'; const CSV_EXTENSION = '.csv'; - /** @var int $position */ + /** @var int */ private $position; - /** @var resource $fileHandle */ + /** @var resource */ private $fileHandle; /** From ad913f0100aa1d994ca10fc6ed13c491e0f2e582 Mon Sep 17 00:00:00 2001 From: Oded Arbel Date: Sun, 7 Feb 2021 11:29:01 +0200 Subject: [PATCH 3/4] write boolean value according to http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#datatype-boolean instead of just "1" for true or "" for false; --- src/Spout/Writer/ODS/Manager/WorksheetManager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Spout/Writer/ODS/Manager/WorksheetManager.php b/src/Spout/Writer/ODS/Manager/WorksheetManager.php index 4dfe9c8..0d6942e 100644 --- a/src/Spout/Writer/ODS/Manager/WorksheetManager.php +++ b/src/Spout/Writer/ODS/Manager/WorksheetManager.php @@ -197,7 +197,8 @@ class WorksheetManager implements WorksheetManagerInterface $data .= ''; } elseif ($cell->isBoolean()) { - $data .= ' office:value-type="boolean" calcext:value-type="boolean" office:boolean-value="' . $cell->getValue() . '">'; + $value = $cell->getValue() ? 'true' : 'false'; + $data .= ' office:value-type="boolean" calcext:value-type="boolean" office:boolean-value="' . $value . '">'; $data .= '' . $cell->getValue() . ''; $data .= ''; } elseif ($cell->isNumeric()) { From 73347517f064b3ef03126db643b7d53bd40c19cf Mon Sep 17 00:00:00 2001 From: Oded Arbel Date: Mon, 8 Feb 2021 15:52:13 +0200 Subject: [PATCH 4/4] added comment with spec link, as requested --- src/Spout/Writer/ODS/Manager/WorksheetManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Spout/Writer/ODS/Manager/WorksheetManager.php b/src/Spout/Writer/ODS/Manager/WorksheetManager.php index 0d6942e..169e4e6 100644 --- a/src/Spout/Writer/ODS/Manager/WorksheetManager.php +++ b/src/Spout/Writer/ODS/Manager/WorksheetManager.php @@ -197,7 +197,7 @@ class WorksheetManager implements WorksheetManagerInterface $data .= ''; } elseif ($cell->isBoolean()) { - $value = $cell->getValue() ? 'true' : 'false'; + $value = $cell->getValue() ? 'true' : 'false'; // boolean-value spec: http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#datatype-boolean $data .= ' office:value-type="boolean" calcext:value-type="boolean" office:boolean-value="' . $value . '">'; $data .= '' . $cell->getValue() . ''; $data .= '';