Skip to content

Commit 5291be2

Browse files
authored
Merge pull request #4256 from oleibman/csvmacle
Get Us Closer to Csv Not Autodetect By Default
2 parents ad02899 + c66ac56 commit 5291be2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/PhpSpreadsheet/Reader/Csv.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ class Csv extends BaseReader
8484
*/
8585
private static $constructorCallback;
8686

87+
/** Will be changed to false in next major release */
88+
public const DEFAULT_TEST_AUTODETECT = true;
89+
8790
/**
8891
* Attempt autodetect line endings (deprecated after PHP8.1)?
8992
*/
90-
private bool $testAutodetect = true;
93+
private bool $testAutodetect = self::DEFAULT_TEST_AUTODETECT;
9194

9295
protected bool $castFormattedNumberToNumeric = false;
9396

tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class CsvLineEndingTest extends TestCase
1212
{
1313
private string $tempFile = '';
1414

15+
private static bool $alwaysFalse = false;
16+
1517
protected function tearDown(): void
1618
{
1719
if ($this->tempFile !== '') {
@@ -30,6 +32,9 @@ public function testEndings(string $ending): void
3032
$data = ['123', '456', '789'];
3133
file_put_contents($filename, implode($ending, $data));
3234
$reader = new Csv();
35+
if (Csv::DEFAULT_TEST_AUTODETECT === self::$alwaysFalse) {
36+
$reader->setTestAutoDetect(true);
37+
}
3338
$spreadsheet = $reader->load($filename);
3439
$sheet = $spreadsheet->getActiveSheet();
3540
self::assertEquals($data[0], $sheet->getCell('A1')->getValue());

0 commit comments

Comments
 (0)