diff --git a/module/report/model.php b/module/report/model.php index 1e330aa910..12495d9fcf 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -514,13 +514,14 @@ class reportModel extends model } /** + * 获取年度月份。 * Get year months. * * @param string $year * @access public * @return array */ - public function getYearMonths($year) + public function getYearMonths(string $year): array { $months = array(); for($i = 1; $i <= 12; $i ++) $months[] = $year . '-' . sprintf('%02d', $i); diff --git a/module/report/test/model/getyearmonths.php b/module/report/test/model/getyearmonths.php index d415d356aa..996ab9ccce 100755 --- a/module/report/test/model/getyearmonths.php +++ b/module/report/test/model/getyearmonths.php @@ -1,7 +1,11 @@ #!/usr/bin/env php gen(1); + su('admin'); /** @@ -17,7 +21,7 @@ pid=1 测试获取 2024 的月份 >> 2024-01,2024-02,2024-03,2024-04,2024-05,2024-06,2024-07,2024-08,2024-09,2024-10,2024-11,2024-12 */ -$year = array(2020, 2021, 2022, 2023, 2024); +$year = array('2020', '2021', '2022', '2023', '2024'); $report = new reportTest(); @@ -25,4 +29,4 @@ r($report->getYearMonthsTest($year[0])) && p() && e('2020-01,2020-02,2020-03,202 r($report->getYearMonthsTest($year[1])) && p() && e('2021-01,2021-02,2021-03,2021-04,2021-05,2021-06,2021-07,2021-08,2021-09,2021-10,2021-11,2021-12'); // 测试获取 2021 的月份 r($report->getYearMonthsTest($year[2])) && p() && e('2022-01,2022-02,2022-03,2022-04,2022-05,2022-06,2022-07,2022-08,2022-09,2022-10,2022-11,2022-12'); // 测试获取 2022 的月份 r($report->getYearMonthsTest($year[3])) && p() && e('2023-01,2023-02,2023-03,2023-04,2023-05,2023-06,2023-07,2023-08,2023-09,2023-10,2023-11,2023-12'); // 测试获取 2023 的月份 -r($report->getYearMonthsTest($year[4])) && p() && e('2024-01,2024-02,2024-03,2024-04,2024-05,2024-06,2024-07,2024-08,2024-09,2024-10,2024-11,2024-12'); // 测试获取 2024 的月份 \ No newline at end of file +r($report->getYearMonthsTest($year[4])) && p() && e('2024-01,2024-02,2024-03,2024-04,2024-05,2024-06,2024-07,2024-08,2024-09,2024-10,2024-11,2024-12'); // 测试获取 2024 的月份 diff --git a/module/report/test/report.class.php b/module/report/test/report.class.php index c1d6d95ecf..ce1beb097e 100644 --- a/module/report/test/report.class.php +++ b/module/report/test/report.class.php @@ -491,13 +491,14 @@ class reportTest } /** + * 测试获取本年的月份。 * Test get year months. * - * @param string $year + * @param string $year * @access public - * @return string + * @return string|array */ - public function getYearMonthsTest($year) + public function getYearMonthsTest(string $year): string|array { $objects = $this->objectModel->getYearMonths($year);