diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 33bee9cdfa..89cbfd5ad1 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -84,10 +84,13 @@ class Csv extends BaseReader */ private static $constructorCallback; + /** Will be changed to false in next major release */ + public const DEFAULT_TEST_AUTODETECT = true; + /** * Attempt autodetect line endings (deprecated after PHP8.1)? */ - private bool $testAutodetect = true; + private bool $testAutodetect = self::DEFAULT_TEST_AUTODETECT; protected bool $castFormattedNumberToNumeric = false; diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php index 28ff9f30fe..f14bdeb137 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php @@ -12,6 +12,8 @@ class CsvLineEndingTest extends TestCase { private string $tempFile = ''; + private static bool $alwaysFalse = false; + protected function tearDown(): void { if ($this->tempFile !== '') { @@ -32,6 +34,9 @@ public function testEndings(string $ending): void $data = ['123', '456', '789']; file_put_contents($filename, implode($ending, $data)); $reader = new Csv(); + if (Csv::DEFAULT_TEST_AUTODETECT === self::$alwaysFalse) { + $reader->setTestAutoDetect(true); + } $spreadsheet = $reader->load($filename); $sheet = $spreadsheet->getActiveSheet(); self::assertEquals($data[0], $sheet->getCell('A1')->getValue());