mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-18 05:57:33 +00:00
Minor Tweak
This commit is contained in:
@@ -562,10 +562,12 @@ class Csv extends BaseReader
|
||||
*/
|
||||
public function setEscapeCharacter(string $escapeCharacter): self
|
||||
{
|
||||
if (PHP_VERSION_ID < 90000) {
|
||||
$this->escapeCharacter = $escapeCharacter;
|
||||
if (PHP_VERSION_ID >= 90000 && $escapeCharacter !== '') {
|
||||
throw new ReaderException('Escape character must be null string for Php9+');
|
||||
}
|
||||
|
||||
$this->escapeCharacter = $escapeCharacter;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,10 @@ class CsvTest extends TestCase
|
||||
|
||||
public function testEscapeCharacters(): void
|
||||
{
|
||||
if (PHP_VERSION_ID >= 90000) {
|
||||
$this->expectException(ReaderException::class);
|
||||
$this->expectExceptionMessage('Escape character must be null string');
|
||||
}
|
||||
$reader = (new Csv())->setEscapeCharacter('"');
|
||||
$worksheet = $reader->load('tests/data/Reader/CSV/backslash.csv')
|
||||
->getActiveSheet();
|
||||
@@ -230,6 +234,10 @@ class CsvTest extends TestCase
|
||||
*/
|
||||
public function testInferSeparator(string $escape, string $delimiter): void
|
||||
{
|
||||
if (PHP_VERSION_ID >= 90000 && $escape !== '') {
|
||||
$this->expectException(ReaderException::class);
|
||||
$this->expectExceptionMessage('Escape character must be null string');
|
||||
}
|
||||
$reader = new Csv();
|
||||
$reader->setEscapeCharacter($escape);
|
||||
$filename = 'tests/data/Reader/CSV/escape.csv';
|
||||
|
||||
Reference in New Issue
Block a user