From dbcab59d3a2d75cdcd6ca8b4bd5c37929d68498c Mon Sep 17 00:00:00 2001 From: Charles Fulton Date: Mon, 3 Feb 2025 10:25:34 -0500 Subject: [PATCH] Code cleanup --- classes/privacy/provider.php | 2 +- classes/writer.php | 10 +++++----- tests/export_test.php | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 2d9bfad..aaffd92 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -41,7 +41,7 @@ class provider implements * * @return string */ - public static function get_reason() : string { + public static function get_reason(): string { return 'privacy:metadata'; } } diff --git a/classes/writer.php b/classes/writer.php index dd13a8c..ad312ee 100644 --- a/classes/writer.php +++ b/classes/writer.php @@ -43,16 +43,16 @@ class writer extends \core\dataformat\base { public $extension = ".md"; /** @var $columns Column headings for the data. */ - private $columns = array(); + private $columns = []; /** @var $columnlength Stores the maximum found record length of each column. */ - private $columnlength = array(); + private $columnlength = []; /** @var $flushed Whether the the preprocessed records have been flushed. */ private $flushed = 0; /** @var $records Stores the records until they're flushed. */ - private $records = array(); + private $records = []; /** * Write the start of the format. The records will be flushed after column length is calculated. @@ -106,7 +106,7 @@ public function write_footer($columns) { */ private function flush() { $this->print_record($this->columns); - $separators = array(); + $separators = []; foreach ($this->columnlength as $key => $length) { $separators[$key] = str_pad('', $length, '-'); } @@ -123,7 +123,7 @@ private function flush() { * @param array $record */ private function print_record($record) { - $values = array(); + $values = []; foreach ($this->columnlength as $key => $length) { $values[] = str_pad($this->sanitize_record($record[$key]), $length); } diff --git a/tests/export_test.php b/tests/export_test.php index 134d156..05fbde9 100644 --- a/tests/export_test.php +++ b/tests/export_test.php @@ -37,14 +37,14 @@ * @copyright 2017 Lafayette College ITS * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class export_test extends \basic_testcase { - public function test_export() { - $fields = array('fruit', 'color'); - $records = array( - array('Apple', 'red'), - array('Banana', 'yellow'), - array('Orange', 'orange') - ); +final class export_test extends \basic_testcase { + public function test_export(): void { + $fields = ['fruit', 'color']; + $records = [ + ['Apple', 'red'], + ['Banana', 'yellow'], + ['Orange', 'orange'], + ]; $downloadrecords = new \ArrayObject($records); $iterator = $downloadrecords->getIterator();