From 02266a6334b51c3dcc0f64fd15860552b78b3cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Bl=C3=A4ul?= Date: Thu, 29 Aug 2024 17:06:16 +0200 Subject: [PATCH] Convert some old array() calls to new [] syntax --- tests/methods/ParseTest.php | 2 +- tests/methods/SaveTest.php | 2 +- tests/methods/UnparseTest.php | 15 ++++++--------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/methods/ParseTest.php b/tests/methods/ParseTest.php index fb514ea..ef1514d 100644 --- a/tests/methods/ParseTest.php +++ b/tests/methods/ParseTest.php @@ -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); diff --git a/tests/methods/SaveTest.php b/tests/methods/SaveTest.php index 23025e0..10a93b3 100644 --- a/tests/methods/SaveTest.php +++ b/tests/methods/SaveTest.php @@ -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); } diff --git a/tests/methods/UnparseTest.php b/tests/methods/UnparseTest.php index 4f414cc..60448dd 100644 --- a/tests/methods/UnparseTest.php +++ b/tests/methods/UnparseTest.php @@ -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); @@ -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); } @@ -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); }