Skip to content

Commit

Permalink
Convert some old array() calls to new [] syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
gogowitsch committed Aug 29, 2024
1 parent 259e9a6 commit 24e229d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/methods/ParseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function testAutoQuotes($file, $enclosure) {
* @return mixed Method return.
*/
private function invokeMethod($object, $methodName, $parameters = []) {
$reflection = new ReflectionClass(get_class($object));
$reflection = new ReflectionClass($object::class);
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);

Expand Down
2 changes: 1 addition & 1 deletion tests/methods/SaveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testSaveWithUnixLineEnding() {

public function testSaveWithNewHeader() {
$this->csv->linefeed = "\n";
$this->csv->titles = array("NewTitle");
$this->csv->titles = ["NewTitle"];
$expected = "NewTitle\n0444\n5555\n";
$this->saveAndCompare($expected);
}
Expand Down
15 changes: 6 additions & 9 deletions tests/methods/UnparseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function setUp(): void {
}

public function testUnparseWithParameters() {
$fields = array('a' => 'AA', 'b' => 'BB');
$fields = ['a' => 'AA', 'b' => 'BB'];
$data = [['a' => 'value1', 'b' => 'value2']];
$csv_object = new Csv();
$csv_string = $csv_object->unparse($data, $fields);
Expand Down Expand Up @@ -52,24 +52,21 @@ public function testUnparseDefaultWithoutHeading() {

public function testUnparseRenameFields() {
$expected = "C1,C2\rvalue1,value2\rvalue3,value4\r";
$this->unparseAndCompare($expected, array("C1", "C2"));
$this->unparseAndCompare($expected, ["C1", "C2"]);
}

public function testReorderFields() {
$expected = "column2,column1\rvalue2,value1\rvalue4,value3\r";
$this->unparseAndCompare($expected, array("column2", "column1"));
$this->unparseAndCompare($expected, ["column2", "column1"]);
}

public function testSubsetFields() {
$expected = "column1\rvalue1\rvalue3\r";
$this->unparseAndCompare($expected, array("column1"));
$this->unparseAndCompare($expected, ["column1"]);
}

public function testReorderAndRenameFields() {
$fields = array(
'column2' => 'C2',
'column1' => 'C1',
);
$fields = ['column2' => 'C2', 'column1' => 'C1'];
$expected = "C2,C1\rvalue2,value1\rvalue4,value3\r";
$this->unparseAndCompare($expected, $fields);
}
Expand Down Expand Up @@ -99,7 +96,7 @@ public function testObjectCells() {
$this->unparseAndCompare($expected);
}

private function unparseAndCompare($expected, $fields = array()) {
private function unparseAndCompare($expected, $fields = []) {
$str = $this->csv->unparse($this->csv->data, $fields);
$this->assertEquals($expected, $str);
}
Expand Down

0 comments on commit 24e229d

Please sign in to comment.