Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master:
  Updated lib to remove array short syntax ([]) to allow lib to support PHP 5.3.
  • Loading branch information
Daniel Lakes committed Mar 15, 2014
2 parents fd9e934 + 3a7909d commit 8565b57
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 31 deletions.
6 changes: 3 additions & 3 deletions Error/Reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Reporter
*/
public function __construct()
{
$this->lineErrors = [];
$this->generalErrors = [];
$this->lineErrors = array();
$this->generalErrors = array();
$this->hasError = false;
}

Expand Down Expand Up @@ -90,7 +90,7 @@ public function addLineError($errorMsg, $lineNumber)
{

if (false === isset($this->lineErrors["$lineNumber"])) {
$this->lineErrors["$lineNumber"] = [];
$this->lineErrors["$lineNumber"] = array();
}
$this->lineErrors["$lineNumber"][] = $errorMsg;
}
Expand Down
2 changes: 1 addition & 1 deletion FileReader/CsvFileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function parse($path)
{
$this->open($path);

$allRowsData = [];
$allRowsData = array();
while (false === $this->endOfFile) {
$data = $this->parseNextRow();

Expand Down
2 changes: 1 addition & 1 deletion FileReader/Factory/CsvFileReaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(EventDispatcherInterface $eventDispatcher)
* @param array $options
* @return CsvFileReaderInterface
*/
public function create(array $options = [])
public function create(array $options = array())
{
$csvFileReaderOptions = new CsvFileReaderOptions($options);

Expand Down
4 changes: 2 additions & 2 deletions FileReader/Factory/CsvFileReaderFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ interface CsvFileReaderFactoryInterface {
* Create
*
* @param array $options
* @return FileReaderInterface
* @return CsvFileReaderInterface
*/
public function create(array $options = []);
public function create(array $options = array());

}
8 changes: 4 additions & 4 deletions FileReader/Options/CsvFileReaderOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CsvFileReaderOptions implements CsvFileReaderOptionsInterface
*
* @var array
*/
private $supportedOptions = [
private $supportedOptions = array(
self::OPTION_LENGTH,
self::OPTION_DELIMITER,
self::OPTION_ENCLOSURE,
Expand All @@ -62,19 +62,19 @@ class CsvFileReaderOptions implements CsvFileReaderOptionsInterface
self::OPTION_USE_LABELS_AS_KEYS,
self::OPTION_VALIDATION,
self::OPTION_PARSER,
];
);

/**
* Supported header policies.
*
* @var array
*/
private $supportedHeaderPolicies = [
private $supportedHeaderPolicies = array(
self::HEADER_POLICY_NO_HEADER,
self::HEADER_POLICY_DISREGARD,
self::HEADER_POLICY_SUB_DATA_OPTIONAL,
self::HEADER_POLICY_SUB_DATA_REQUIRED,
];
);

/**
* Length Option.
Expand Down
4 changes: 2 additions & 2 deletions FileReader/Response/ReaderResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ReaderResponse
*/
public function __construct()
{
$this->errors = [];
$this->errors = array();
$this->success = true;
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public function addErrorForRow(\Exception $error)
*/
public function clearErrors()
{
$this->errors = [];
$this->errors = array();
$this->success = true;
}

Expand Down
12 changes: 7 additions & 5 deletions Subscriber/ParseErrorSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ public function __construct(
*/
public static function getSubscribedEvents()
{
return [
CsvParseErrorEvent::EVENT_KEY => [
['updateReporter', static::UPDATE_REPORTER_PRIORITY],
],
];
return array(
CsvParseErrorEvent::EVENT_KEY => array(
array(
'updateReporter', static::UPDATE_REPORTER_PRIORITY,
),
),
);
}


Expand Down
32 changes: 19 additions & 13 deletions Tests/FileReader/SimpleReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace Nerdery\CsvBundle\Tests\FileReader;

use Nerdery\CsvBundle\FileReader\CsvFileReader;
use Nerdery\CsvBundle\Exception\NoHeaderForDataColumnException;
use \PHPUnit_Framework_TestCase as TestCase;

/**
Expand All @@ -28,11 +27,14 @@ class CsvFileReaderTest extends TestCase {
*/
public function testImportsValidFileWithNoColumnVariance()
{
$reader = new CsvFileReader([]);
$this->markTestIncomplete('need to update this test class to inject additional dependencies');
$reader = new CsvFileReader(
array()
);

$reader->open(__DIR__ . '/../../TestFiles/validWithNoColumnVariance.csv');

$rowOne = $reader->getKeyedRowData();
$rowOne = $reader->getRowData();
$this->assertEquals(
'apple', $rowOne['fruitName']
);
Expand All @@ -46,7 +48,7 @@ public function testImportsValidFileWithNoColumnVariance()
'crisp', $rowOne['taste']
);

$rowTwo = $reader->getKeyedRowData();
$rowTwo = $reader->getRowData();
$this->assertEquals(
'banana', $rowTwo['fruitName']
);
Expand All @@ -60,7 +62,7 @@ public function testImportsValidFileWithNoColumnVariance()
'creamy', $rowTwo['taste']
);

$rowThree = $reader->getKeyedRowData();
$rowThree = $reader->getRowData();
$this->assertEquals(
'pear', $rowThree['fruitName']
);
Expand All @@ -74,7 +76,7 @@ public function testImportsValidFileWithNoColumnVariance()
'crisp', $rowThree['taste']
);

$rowFour = $reader->getKeyedRowData();
$rowFour = $reader->getRowData();
$this->assertFalse($rowFour);
}

Expand All @@ -87,13 +89,15 @@ public function testImportsValidFileWithNoColumnVariance()
*/
public function testImportsValidFileWithColumnVariance()
{
$this->markTestIncomplete('need to update this test class to inject additional dependencies');

$reader = new CsvFileReader(
[]
array()
);

$reader->open(__DIR__ . '/../../TestFiles/validWithNoColumnVariance.csv');

$rowOne = $reader->getKeyedRowData();
$rowOne = $reader->getRowData();
$this->assertEquals(
'apple', $rowOne['fruitName']
);
Expand All @@ -116,7 +120,7 @@ public function testImportsValidFileWithColumnVariance()
'Fuji', $rowOne['variety3']
);

$rowTwo = $reader->getKeyedRowData();
$rowTwo = $reader->getRowData();
$this->assertEquals(
'banana', $rowTwo['fruitName']
);
Expand All @@ -135,7 +139,7 @@ public function testImportsValidFileWithColumnVariance()
$this->assertNull($rowTwo['variety2']);
$this->assertNull($rowTwo['variety3']);

$rowThree = $reader->getKeyedRowData();
$rowThree = $reader->getRowData();
$this->assertEquals(
'pear', $rowThree['fruitName']
);
Expand All @@ -156,7 +160,7 @@ public function testImportsValidFileWithColumnVariance()
);
$this->assertNull($rowThree['variety3']);

$rowFour = $reader->getKeyedRowData();
$rowFour = $reader->getRowData();
$this->assertFalse($rowFour);
}

Expand All @@ -168,8 +172,10 @@ public function testImportsValidFileWithColumnVariance()
*/
public function testThrowsExceptionIfTooManyColumnsInDataRow()
{
$this->markTestIncomplete('need to update this test class to inject additional dependencies');

$reader = new CsvFileReader(
[]
array()
);

$reader->open(__DIR__ . '/../../TestFiles/invalidTooManyColumnsInDataRows.csv');
Expand All @@ -182,7 +188,7 @@ public function testThrowsExceptionIfTooManyColumnsInDataRow()
'be <= the number of labels.'
);

$rowOne = $reader->getKeyedRowData();
$rowOne = $reader->getRowData();

}
}
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
{
"name": "Thomas Houfek",
"email": "thomas.houfek@nerdery.com"
},
{
"name": "Daniel Lakes",
"email": "daniel.lakes@nerdery.com"
}
],
"require": {
Expand Down

0 comments on commit 8565b57

Please sign in to comment.