diff options
author | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2015-05-18 17:38:07 +0200 |
---|---|---|
committer | Ignace Nyamagana Butera <nyamsprod@gmail.com> | 2015-05-20 09:13:03 +0200 |
commit | e36bc99a971be408805aa96c933dad1183631a0a (patch) | |
tree | f32be415333280179324a671d96380bc317a48e9 | |
parent | 3a2a199d686bc8b52689b74d5a66cb2e9b9370c9 (diff) | |
download | csv-e36bc99a971be408805aa96c933dad1183631a0a.zip csv-e36bc99a971be408805aa96c933dad1183631a0a.tar.gz csv-e36bc99a971be408805aa96c933dad1183631a0a.tar.bz2 |
bug fix for issue #99
-rw-r--r-- | CHANGELOG.md | 6 | ||||
-rw-r--r-- | src/AbstractCsv.php | 2 | ||||
-rw-r--r-- | src/Config/Controls.php | 2 | ||||
-rw-r--r-- | src/Config/Output.php | 2 | ||||
-rw-r--r-- | src/Exception/InvalidRowException.php | 2 | ||||
-rw-r--r-- | src/Modifier/MapIterator.php | 2 | ||||
-rw-r--r-- | src/Modifier/QueryFilter.php | 6 | ||||
-rw-r--r-- | src/Modifier/RowFilter.php | 2 | ||||
-rw-r--r-- | src/Modifier/StreamFilter.php | 2 | ||||
-rw-r--r-- | src/Plugin/ColumnConsistencyValidator.php | 2 | ||||
-rw-r--r-- | src/Plugin/ForbiddenNullValuesValidator.php | 2 | ||||
-rw-r--r-- | src/Plugin/SkipNullValuesFormatter.php | 2 | ||||
-rw-r--r-- | src/Reader.php | 2 | ||||
-rw-r--r-- | src/Writer.php | 2 | ||||
-rw-r--r-- | test/ControlsTest.php | 33 |
15 files changed, 56 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a510ecc..9570f58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ #Changelog All Notable changes to `League\Csv` will be documented in this file +## 7.1.1 - 2015-05-20 + +### Fixed + +- `SplFileObject` flags were not always applied using query filter [bug fix #99](http://github.com/thephpleague/csv/issues/99) + ## 7.1.0 - 2015-05-06 ### Added diff --git a/src/AbstractCsv.php b/src/AbstractCsv.php index bf967aa..72b1959 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 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Config/Controls.php b/src/Config/Controls.php index ba6c76a..92194a5 100644 --- a/src/Config/Controls.php +++ b/src/Config/Controls.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Config/Output.php b/src/Config/Output.php index 3d85a1f..dd6e1ac 100644 --- a/src/Config/Output.php +++ b/src/Config/Output.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Exception/InvalidRowException.php b/src/Exception/InvalidRowException.php index 9649cf8..0fb0227 100644 --- a/src/Exception/InvalidRowException.php +++ b/src/Exception/InvalidRowException.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Modifier/MapIterator.php b/src/Modifier/MapIterator.php index 504b9b2..2306f1c 100644 --- a/src/Modifier/MapIterator.php +++ b/src/Modifier/MapIterator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Modifier/QueryFilter.php b/src/Modifier/QueryFilter.php index 739028d..03beb52 100644 --- a/src/Modifier/QueryFilter.php +++ b/src/Modifier/QueryFilter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE @@ -241,6 +241,10 @@ trait QueryFilter */ protected function applyBomStripping(Iterator $iterator) { + if (! $this->strip_bom) { + return $iterator; + } + if (! $this->isBomStrippable()) { $this->strip_bom = false; return $iterator; diff --git a/src/Modifier/RowFilter.php b/src/Modifier/RowFilter.php index 8f8f796..b340a68 100644 --- a/src/Modifier/RowFilter.php +++ b/src/Modifier/RowFilter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Modifier/StreamFilter.php b/src/Modifier/StreamFilter.php index a948101..76321c4 100644 --- a/src/Modifier/StreamFilter.php +++ b/src/Modifier/StreamFilter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Plugin/ColumnConsistencyValidator.php b/src/Plugin/ColumnConsistencyValidator.php index da8b0fe..aa013b3 100644 --- a/src/Plugin/ColumnConsistencyValidator.php +++ b/src/Plugin/ColumnConsistencyValidator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Plugin/ForbiddenNullValuesValidator.php b/src/Plugin/ForbiddenNullValuesValidator.php index c9f0ca8..c4c36ae 100644 --- a/src/Plugin/ForbiddenNullValuesValidator.php +++ b/src/Plugin/ForbiddenNullValuesValidator.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/src/Plugin/SkipNullValuesFormatter.php b/src/Plugin/SkipNullValuesFormatter.php index b00403c..37118e0 100644 --- a/src/Plugin/SkipNullValuesFormatter.php +++ b/src/Plugin/SkipNullValuesFormatter.php @@ -4,7 +4,7 @@ * * @license http://opensource.org/licenses/MIT * @link https://github.com/thephpleague/csv/ -* @version 7.1.0 +* @version 7.1.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 64f7238..2955e11 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 7.1.0 +* @version 7.1.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 a25e29f..824203a 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 7.1.0 +* @version 7.1.1 * @package League.csv * * For the full copyright and license information, please view the LICENSE diff --git a/test/ControlsTest.php b/test/ControlsTest.php index ea4c45c..d1837ce 100644 --- a/test/ControlsTest.php +++ b/test/ControlsTest.php @@ -189,4 +189,37 @@ class ControlsTest extends PHPUnit_Framework_TestCase $csv->setNewline("\r\n"); $this->assertSame("\r\n", $csv->getNewline()); } + + /** + * @param $flag + * @param $line_count + * @dataProvider appliedFlagsProvider + */ + public function testAppliedFlags($flag, $line_count) + { + $path = __DIR__."/data/tmp.txt"; + $obj = new SplFileObject($path, "w+"); + $obj->fwrite("1st\n2nd\n"); + $reader = Reader::createFromFileObject($obj); + $reader->setFlags($flag); + $this->assertCount($line_count, $reader->fetchAll()); + unlink($path); + } + + public function appliedFlagsProvider() + { + return [ + "NONE" => [0, 3], + "DROP_NEW_LINE" => [SplFileObject::DROP_NEW_LINE, 3], + "READ_AHEAD" => [SplFileObject::READ_AHEAD, 3], + "SKIP_EMPTY" => [SplFileObject::SKIP_EMPTY, 2], + "READ_AHEAD|DROP_NEW_LINE" => [SplFileObject::READ_AHEAD|SplFileObject::DROP_NEW_LINE, 3], + "READ_AHEAD|SKIP_EMPTY" => [SplFileObject::READ_AHEAD|SplFileObject::SKIP_EMPTY, 2], + "DROP_NEW_LINE|SKIP_EMPTY" => [SplFileObject::DROP_NEW_LINE|SplFileObject::SKIP_EMPTY, 2], + "READ_AHEAD|DROP_NEW_LINE|SKIP_EMPTY" => [ + SplFileObject::READ_AHEAD|SplFileObject::DROP_NEW_LINE|SplFileObject::SKIP_EMPTY, + 2 + ], + ]; + } } |