Skip to content

Commit

Permalink
bug fix for issue #99
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed May 20, 2015
1 parent 3a2a199 commit e36bc99
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Controls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Config/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidRowException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Modifier/MapIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/Modifier/QueryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -241,6 +241,10 @@ public function clearFilter()
*/
protected function applyBomStripping(Iterator $iterator)
{
if (! $this->strip_bom) {
return $iterator;
}

if (! $this->isBomStrippable()) {
$this->strip_bom = false;
return $iterator;
Expand Down
2 changes: 1 addition & 1 deletion src/Modifier/RowFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Modifier/StreamFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/ColumnConsistencyValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/ForbiddenNullValuesValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/SkipNullValuesFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions test/ControlsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,37 @@ public function testCustomNewline()
$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
],
];
}
}

0 comments on commit e36bc99

Please sign in to comment.