Merge branch 'master' into fix-ods-boolean

This commit is contained in:
Adrien Loison 2021-02-08 17:15:08 +01:00 committed by GitHub
commit 65e875eed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 46 additions and 33 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
/vendor /vendor
/composer.lock /composer.lock
/.php_cs.cache /.php_cs.cache
/.phpunit.result.cache

View File

@ -5,16 +5,16 @@ language: php
matrix: matrix:
include: include:
- php: 7.1
env: WITH_CS=true
- php: 7.1
env: WITH_PHPUNIT=true WITH_COVERAGE=true
- php: 7.2 - php: 7.2
env: WITH_PHPUNIT=true env: WITH_PHPUNIT=true
- php: 7.3 - php: 7.3
env: WITH_PHPUNIT=true env: WITH_PHPUNIT=true
- php: 7.3
env: WITH_PHPUNIT=true WITH_COVERAGE=true
- php: 7.4 - php: 7.4
env: WITH_PHPUNIT=true env: WITH_PHPUNIT=true
- php: 8.0
env: WITH_PHPUNIT=true
cache: cache:

View File

@ -20,7 +20,7 @@ Full documentation can be found at [https://opensource.box.com/spout/](https://o
## Requirements ## Requirements
* PHP version 7.1 or higher * PHP version 7.2 or higher
* PHP extension `php_zip` enabled * PHP extension `php_zip` enabled
* PHP extension `php_xmlreader` enabled * PHP extension `php_xmlreader` enabled

View File

@ -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. 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 Reader changes
-------------- --------------

View File

@ -12,12 +12,12 @@
} }
], ],
"require": { "require": {
"php": ">=7.1.0", "php": ">=7.2.0",
"ext-zip": "*", "ext-zip": "*",
"ext-xmlreader" : "*" "ext-xmlreader" : "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^7", "phpunit/phpunit": "^8",
"friendsofphp/php-cs-fixer": "^2" "friendsofphp/php-cs-fixer": "^2"
}, },
"suggest": { "suggest": {
@ -36,7 +36,7 @@
}, },
"config": { "config": {
"platform": { "platform": {
"php": "7.1" "php": "7.2"
} }
} }
} }

View File

@ -10,7 +10,7 @@ This guide will help you install {{ site.spout_html }} and teach you how to use
## Requirements ## Requirements
* PHP version 7.1 or higher * PHP version 7.2 or higher
* PHP extension `ext-zip` enabled * PHP extension `ext-zip` enabled
* PHP extension `ext-xmlreader` enabled * PHP extension `ext-xmlreader` enabled

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="tests/bootstrap.php" bootstrap="tests/bootstrap.php"
colors="true" colors="true"
convertErrorsToExceptions="false" convertErrorsToExceptions="false"

View File

@ -122,6 +122,6 @@ class RowTest extends \PHPUnit\Framework\TestCase
->setStyle($this->getStyleMock()) ->setStyle($this->getStyleMock())
->setCells([]); ->setCells([]);
$this->assertInternalType('object', $row); $this->assertInstanceOf(Row::class, $row);
} }
} }

View File

@ -16,7 +16,7 @@ class FileSystemHelperTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp() : void
{ {
$baseFolder = \sys_get_temp_dir(); $baseFolder = \sys_get_temp_dir();
$this->fileSystemHelper = new FileSystemHelper($baseFolder); $this->fileSystemHelper = new FileSystemHelper($baseFolder);

View File

@ -14,7 +14,7 @@ class OptionsManagerTest extends TestCase
*/ */
protected $optionsManager; protected $optionsManager;
protected function setUp() protected function setUp(): void
{ {
$this->optionsManager = new class() extends OptionsManagerAbstract { $this->optionsManager = new class() extends OptionsManagerAbstract {
protected function getSupportedOptions() protected function getSupportedOptions()

View File

@ -295,6 +295,10 @@ class ReaderTest extends TestCase
*/ */
public function testReadShouldBeProtectedAgainstBillionLaughsAttack() 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); $startTime = microtime(true);
$fileName = 'attack_billion_laughs.ods'; $fileName = 'attack_billion_laughs.ods';
@ -318,6 +322,10 @@ class ReaderTest extends TestCase
*/ */
public function testReadShouldBeProtectedAgainstQuadraticBlowupAttack() 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); $startTime = microtime(true);
$fileName = 'attack_quadratic_blowup.ods'; $fileName = 'attack_quadratic_blowup.ods';

View File

@ -25,7 +25,7 @@ class SharedStringsManagerTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
$this->sharedStringsManager = null; $this->sharedStringsManager = null;
} }
@ -33,7 +33,7 @@ class SharedStringsManagerTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function tearDown() public function tearDown(): void
{ {
if ($this->sharedStringsManager !== null) { if ($this->sharedStringsManager !== null) {
$this->sharedStringsManager->cleanup(); $this->sharedStringsManager->cleanup();

View File

@ -539,6 +539,10 @@ class ReaderTest extends TestCase
*/ */
public function testReadShouldBeProtectedAgainstQuadraticBlowupAttack() 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); $startTime = microtime(true);
$this->getAllRowsForFile('attack_quadratic_blowup.xlsx'); $this->getAllRowsForFile('attack_quadratic_blowup.xlsx');

View File

@ -101,7 +101,7 @@ class WriterTest extends TestCase
]); ]);
$writtenContent = $this->writeToCsvFileAndReturnWrittenContent($allRows, 'csv_with_utf8_bom.csv'); $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); $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');
} }
/** /**

View File

@ -18,7 +18,7 @@ class SheetTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
$this->sheetManager = new SheetManager(new StringHelper()); $this->sheetManager = new SheetManager(new StringHelper());
} }

View File

@ -18,7 +18,7 @@ class StyleMergerTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
$this->styleMerger = new StyleMerger(); $this->styleMerger = new StyleMerger();
} }

View File

@ -20,7 +20,7 @@ class StyleRegistryTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
$this->defaultStyle = (new StyleBuilder())->build(); $this->defaultStyle = (new StyleBuilder())->build();
$this->styleRegistry = new StyleRegistry($this->defaultStyle); $this->styleRegistry = new StyleRegistry($this->defaultStyle);

View File

@ -89,7 +89,7 @@ class SheetTest extends TestCase
$pathToContentFile = $resourcePath . '#content.xml'; $pathToContentFile = $resourcePath . '#content.xml';
$xmlContents = file_get_contents('zip://' . $pathToContentFile); $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'; $pathToWorkbookFile = $resourcePath . '#content.xml';
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile); $xmlContents = file_get_contents('zip://' . $pathToWorkbookFile);
$this->assertContains("table:name=\"$expectedName\"", $xmlContents, $message); $this->assertStringContainsString("table:name=\"$expectedName\"", $xmlContents, $message);
} }
} }

View File

@ -547,7 +547,7 @@ class WriterTest extends TestCase
$pathToContentFile = $resourcePath . '#content.xml'; $pathToContentFile = $resourcePath . '#content.xml';
$xmlContents = file_get_contents('zip://' . $pathToContentFile); $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); $sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex);
$valueAsXmlString = "<text:p>$value</text:p>"; $valueAsXmlString = "<text:p>$value</text:p>";
$this->assertContains($valueAsXmlString, $sheetXmlAsString, $message); $this->assertStringContainsString($valueAsXmlString, $sheetXmlAsString, $message);
} }
/** /**
@ -577,7 +577,7 @@ class WriterTest extends TestCase
$sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex); $sheetXmlAsString = $this->getSheetXmlNodeAsString($fileName, $sheetIndex);
$valueAsXmlString = "<text:p>$value</text:p>"; $valueAsXmlString = "<text:p>$value</text:p>";
$this->assertNotContains($valueAsXmlString, $sheetXmlAsString, $message); $this->assertStringNotContainsString($valueAsXmlString, $sheetXmlAsString, $message);
} }
/** /**

View File

@ -30,7 +30,7 @@ class WriterWithStyleTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
$this->defaultStyle = (new StyleBuilder())->build(); $this->defaultStyle = (new StyleBuilder())->build();
} }

View File

@ -89,7 +89,7 @@ class SheetTest extends TestCase
$pathToWorkbookFile = $resourcePath . '#xl/workbook.xml'; $pathToWorkbookFile = $resourcePath . '#xl/workbook.xml';
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile); $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'; $pathToWorkbookFile = $resourcePath . '#xl/workbook.xml';
$xmlContents = file_get_contents('zip://' . $pathToWorkbookFile); $xmlContents = file_get_contents('zip://' . $pathToWorkbookFile);
$this->assertContains("<sheet name=\"$expectedName\"", $xmlContents, $message); $this->assertStringContainsString("<sheet name=\"$expectedName\"", $xmlContents, $message);
} }
} }

View File

@ -608,7 +608,7 @@ class WriterTest extends TestCase
$pathToSheetFile = $resourcePath . '#xl/worksheets/sheet' . $sheetIndex . '.xml'; $pathToSheetFile = $resourcePath . '#xl/worksheets/sheet' . $sheetIndex . '.xml';
$xmlContents = file_get_contents('zip://' . $pathToSheetFile); $xmlContents = file_get_contents('zip://' . $pathToSheetFile);
$this->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'; $pathToSheetFile = $resourcePath . '#xl/worksheets/sheet' . $sheetIndex . '.xml';
$xmlContents = file_get_contents('zip://' . $pathToSheetFile); $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'; $pathToSharedStringsFile = $resourcePath . '#xl/sharedStrings.xml';
$xmlContents = file_get_contents('zip://' . $pathToSharedStringsFile); $xmlContents = file_get_contents('zip://' . $pathToSharedStringsFile);
$this->assertContains($sharedString, $xmlContents, $message); $this->assertStringContainsString($sharedString, $xmlContents, $message);
} }
} }

View File

@ -32,7 +32,7 @@ class WriterWithStyleTest extends TestCase
/** /**
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
$this->defaultStyle = (new StyleBuilder())->build(); $this->defaultStyle = (new StyleBuilder())->build();
} }