From 5dc305e7958190bcab0cc2778888a4f658d29aa1 Mon Sep 17 00:00:00 2001 From: Ignace Nyamagana Butera Date: Mon, 21 Aug 2017 15:40:04 +0200 Subject: [PATCH] bug fix Writer applying CSV controls #244 --- CHANGELOG.md | 18 ++++++++++++++++++ src/AbstractCsv.php | 2 +- src/ByteSequence.php | 2 +- src/CannotInsertRecord.php | 2 +- src/CharsetConverter.php | 2 +- src/ColumnConsistency.php | 2 +- src/Exception.php | 2 +- src/HTMLConverter.php | 2 +- src/MapIterator.php | 2 +- src/RFC4180Field.php | 2 +- src/Reader.php | 2 +- src/ResultSet.php | 2 +- src/Statement.php | 2 +- src/Stream.php | 2 +- src/Writer.php | 4 ++-- src/XMLConverter.php | 2 +- src/functions.php | 2 +- tests/WriterTest.php | 3 ++- 18 files changed, 37 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea510d4c..8dc22eb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ All Notable changes to `Csv` will be documented in this file +## 9.0.1 - 2017-08-21 + +### Added + +- Nothing + +### Deprecated + +- Nothing + +### Fixed + +- CSV controls not applied when calling Writer::insertOne + +### Removed + +- Nothing + ## 9.0.0 - 2017-08-18 ### Added diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index 23ddf45b..a5f00955 100644 --- a/src/AbstractCsv.php +++ b/src/AbstractCsv.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/ByteSequence.php b/src/ByteSequence.php index 2f77a84f..d6a400ed 100644 --- a/src/ByteSequence.php +++ b/src/ByteSequence.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/CannotInsertRecord.php b/src/CannotInsertRecord.php index 2877b022..0a53ec4b 100644 --- a/src/CannotInsertRecord.php +++ b/src/CannotInsertRecord.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/CharsetConverter.php b/src/CharsetConverter.php index b36c1c2f..c8c36eac 100644 --- a/src/CharsetConverter.php +++ b/src/CharsetConverter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/ColumnConsistency.php b/src/ColumnConsistency.php index 1446c6d2..c62e8db7 100644 --- a/src/ColumnConsistency.php +++ b/src/ColumnConsistency.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Exception.php b/src/Exception.php index ab3ee03e..276e0654 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/HTMLConverter.php b/src/HTMLConverter.php index 7d4bc2ef..f8ea3801 100644 --- a/src/HTMLConverter.php +++ b/src/HTMLConverter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/MapIterator.php b/src/MapIterator.php index 43dd9b93..bab41809 100644 --- a/src/MapIterator.php +++ b/src/MapIterator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/RFC4180Field.php b/src/RFC4180Field.php index 18520ee8..0ef3f7e8 100644 --- a/src/RFC4180Field.php +++ b/src/RFC4180Field.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Reader.php b/src/Reader.php index a70e75ae..a09e4222 100644 --- a/src/Reader.php +++ b/src/Reader.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/ResultSet.php b/src/ResultSet.php index 39c5ae46..d913b972 100644 --- a/src/ResultSet.php +++ b/src/ResultSet.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Statement.php b/src/Statement.php index 5ddf97b1..8bec8c8c 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Stream.php b/src/Stream.php index 01f7e64a..26b5e448 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Writer.php b/src/Writer.php index 62ff8649..02e9ca26 100644 --- a/src/Writer.php +++ b/src/Writer.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -125,7 +125,7 @@ public function insertOne(array $record): int { $record = array_reduce($this->formatters, [$this, 'formatRecord'], $record); $this->validateRecord($record); - $bytes = $this->document->fputcsv($record, ...$this->document->getCsvControl()); + $bytes = $this->document->fputcsv($record, $this->delimiter, $this->enclosure, $this->escape); if (!$bytes) { throw CannotInsertRecord::triggerOnInsertion($record); } diff --git a/src/XMLConverter.php b/src/XMLConverter.php index 75ef880f..b26ce22d 100644 --- a/src/XMLConverter.php +++ b/src/XMLConverter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/functions.php b/src/functions.php index 53d84a84..d40ca551 100644 --- a/src/functions.php +++ b/src/functions.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 9.0.0 +* @version 9.0.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/tests/WriterTest.php b/tests/WriterTest.php index d46fa002..42babad0 100644 --- a/tests/WriterTest.php +++ b/tests/WriterTest.php @@ -152,6 +152,7 @@ public function testToString() { $fp = fopen('php://temp', 'r+'); $csv = Writer::createFromStream($fp); + $csv->setDelimiter('|'); $expected = [ ['john', 'doe', 'john.doe@example.com'], @@ -162,7 +163,7 @@ public function testToString() $csv->insertOne($row); } - $expected = "john,doe,john.doe@example.com\njane,doe,jane.doe@example.com\n"; + $expected = "john|doe|john.doe@example.com\njane|doe|jane.doe@example.com\n"; $this->assertSame($expected, $csv->__toString()); $csv = null; fclose($fp);