Skip to content

Commit

Permalink
Merge pull request #59 from GrahamCampbell/cs
Browse files Browse the repository at this point in the history
CS Fixes
  • Loading branch information
nyamsprod committed Nov 11, 2014
2 parents d648bf7 + 5eb4040 commit 3c5ef23
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion examples/merge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
error_reporting(-1);
ini_set('display_errors', '1');

use League\Csv\Writer;
use League\Csv\Reader;
use League\Csv\Writer;

require '../vendor/autoload.php';

Expand Down
2 changes: 1 addition & 1 deletion examples/stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
}
$writer->insertAll([
'je,suis,toto,le,héros',
'je,<strong>suis</strong>,toto,le,héros'
'je,<strong>suis</strong>,toto,le,héros',
]);

echo $writer->newReader()->toHTML(), PHP_EOL;
Expand Down
2 changes: 1 addition & 1 deletion examples/switchmode.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$writer->insertOne('Ben;7;M;2004');
$writer->insertAll([
'Benjamin;118;M;2004',
['Benoit', '6', 'M', '2004']
['Benoit', '6', 'M', '2004'],
]);

//we create a Reader object from the Writer object
Expand Down
2 changes: 1 addition & 1 deletion examples/writing.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

require '../vendor/autoload.php';

$writer = Writer::createFromFileObject(new SplTempFileObject); //the CSV file will be created into a temporary File
$writer = Writer::createFromFileObject(new SplTempFileObject()); //the CSV file will be created into a temporary File
$writer->setDelimiter("\t"); //the delimiter will be the tab character
$writer->setEncodingFrom("utf-8");

Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">

<testsuites>
<testsuite name="League CSV Test Suite">
<directory>test</directory>
Expand All @@ -30,5 +30,5 @@
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>

</phpunit>
2 changes: 1 addition & 1 deletion scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ tools:
excluded_dirs: [vendor, test, examples]
php_cpd:
enabled: true
excluded_dirs: [vendor, test, examples]
excluded_dirs: [vendor, test, examples]
2 changes: 1 addition & 1 deletion src/AbstractCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public static function createFromString($str)
'the submitted data must be a string or an object implementing the `__toString` method'
);
}
$obj = new SplTempFileObject;
$obj = new SplTempFileObject();
$obj->fwrite((string) $str.PHP_EOL);

return static::createFromFileObject($obj);
Expand Down
14 changes: 7 additions & 7 deletions test/CsvTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CsvTest extends PHPUnit_Framework_TestCase

public function setUp()
{
$csv = new SplTempFileObject;
$csv = new SplTempFileObject();
foreach ($this->expected as $row) {
$csv->fputcsv($row);
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public function testCreateFromPathWithPHPWrapper()
*/
public function testCreateFromPathWithSplTempFileObject()
{
Reader::createFromPath(new SplTempFileObject);
Reader::createFromPath(new SplTempFileObject());
}

public function testCreateFromString()
Expand Down Expand Up @@ -116,15 +116,15 @@ public function testDetectDelimiterListWithInvalidRowLimit()

public function testDetectDelimiterListWithNoCSV()
{
$file = new SplTempFileObject;
$file = new SplTempFileObject();
$file->fwrite("How are you today ?\nI'm doing fine thanks!");
$csv = Writer::createFromFileObject($file);
$this->assertSame([], $csv->detectDelimiterList(5, ['toto', '|']));
}

public function testDetectDelimiterListWithInconsistentCSV()
{
$data = new SplTempFileObject;
$data = new SplTempFileObject();
$data->setCsvControl(';');
$data->fputcsv(['toto', 'tata', 'tutu']);
$data->setCsvControl('|');
Expand Down Expand Up @@ -166,7 +166,7 @@ public function testEnclosure()
*/
public function testCreateFromStringFromNotStringableObject()
{
Reader::createFromString(new DateTime);
Reader::createFromString(new DateTime());
}

/**
Expand Down Expand Up @@ -313,7 +313,7 @@ public function testappendStreamFilter()
*/
public function testFailedprependStreamFilter()
{
$csv = new Reader(new SplTempFileObject);
$csv = new Reader(new SplTempFileObject());
$this->assertFalse($csv->isActiveStreamFilter());
$csv->prependStreamFilter('string.toupper');
}
Expand All @@ -324,7 +324,7 @@ public function testFailedprependStreamFilter()
*/
public function testFailedapppendStreamFilter()
{
$csv = new Writer(new SplTempFileObject);
$csv = new Writer(new SplTempFileObject());
$this->assertFalse($csv->isActiveStreamFilter());
$csv->appendStreamFilter('string.toupper');
}
Expand Down
8 changes: 4 additions & 4 deletions test/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ReaderTest extends PHPUnit_Framework_TestCase

public function setUp()
{
$csv = new SplTempFileObject;
$csv = new SplTempFileObject();
foreach ($this->expected as $row) {
$csv->fputcsv($row);
}
Expand Down Expand Up @@ -117,7 +117,7 @@ public function testSortBy2()
$csv->addSortBy($func);
$this->assertSame([
['john', 'doe', '[email protected]'],
['john', 'doe', '[email protected]']
['john', 'doe', '[email protected]'],
], $csv->fetchAll());
}

Expand Down Expand Up @@ -190,10 +190,10 @@ public function testFetchColEmptyCol()
{
$raw = [
['john', 'doe'],
['lara', 'croft', '[email protected]']
['lara', 'croft', '[email protected]'],
];

$file = new SplTempFileObject;
$file = new SplTempFileObject();
foreach ($raw as $row) {
$file->fputcsv($row);
}
Expand Down
9 changes: 4 additions & 5 deletions test/WriterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
*/
class WriterTest extends PHPUnit_Framework_TestCase
{

private $csv;

public function setUp()
{
$this->csv = Writer::createFromFileObject(new SplTempFileObject);
$this->csv = Writer::createFromFileObject(new SplTempFileObject());
}

public function tearDown()
Expand Down Expand Up @@ -165,7 +164,7 @@ public function testAutoDetectColumnsCount()
*/
public function testFailedInsertWithWrongData()
{
$this->csv->insertOne(new DateTime);
$this->csv->insertOne(new DateTime());
}

/**
Expand All @@ -174,7 +173,7 @@ public function testFailedInsertWithWrongData()
*/
public function testFailedInsertWithMultiDimensionArray()
{
$this->csv->insertOne(['john', new DateTime]);
$this->csv->insertOne(['john', new DateTime()]);
}

public function testSave()
Expand All @@ -201,7 +200,7 @@ public function testSave()
*/
public function testFailedSaveWithWrongType()
{
$this->csv->insertAll(new DateTime);
$this->csv->insertAll(new DateTime());
}

public function testGetReader()
Expand Down

0 comments on commit 3c5ef23

Please sign in to comment.