diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml index 3ea36fd..d428694 100755 --- a/.github/workflows/moodle-plugin-ci.yml +++ b/.github/workflows/moodle-plugin-ci.yml @@ -30,35 +30,29 @@ jobs: fail-fast: false matrix: include: - - php: 7.4 - moodle-branch: MOODLE_401_STABLE - database: mariadb - - php: 7.4 - moodle-branch: MOODLE_401_STABLE - database: pgsql - - php: 8.0 - moodle-branch: MOODLE_401_STABLE + - php: 8.1 + moodle-branch: MOODLE_402_STABLE database: mariadb - - php: 8.0 - moodle-branch: MOODLE_401_STABLE + - php: 8.1 + moodle-branch: MOODLE_402_STABLE database: pgsql - php: 8.1 - moodle-branch: MOODLE_401_STABLE + moodle-branch: MOODLE_403_STABLE database: mariadb - php: 8.1 - moodle-branch: MOODLE_401_STABLE + moodle-branch: MOODLE_403_STABLE database: pgsql - php: 8.1 - moodle-branch: MOODLE_402_STABLE + moodle-branch: MOODLE_404_STABLE database: mariadb - php: 8.1 - moodle-branch: MOODLE_402_STABLE + moodle-branch: MOODLE_404_STABLE database: pgsql - php: 8.1 - moodle-branch: MOODLE_403_STABLE + moodle-branch: MOODLE_405_STABLE database: mariadb - php: 8.1 - moodle-branch: MOODLE_403_STABLE + moodle-branch: MOODLE_405_STABLE database: pgsql - php: 8.2 moodle-branch: MOODLE_402_STABLE @@ -72,10 +66,34 @@ jobs: - php: 8.2 moodle-branch: MOODLE_403_STABLE database: pgsql + - php: 8.2 + moodle-branch: MOODLE_404_STABLE + database: mariadb + - php: 8.2 + moodle-branch: MOODLE_404_STABLE + database: pgsql + - php: 8.2 + moodle-branch: MOODLE_405_STABLE + database: mariadb + - php: 8.2 + moodle-branch: MOODLE_405_STABLE + database: pgsql + - php: 8.3 + moodle-branch: MOODLE_404_STABLE + database: mariadb + - php: 8.3 + moodle-branch: MOODLE_404_STABLE + database: pgsql + - php: 8.3 + moodle-branch: MOODLE_405_STABLE + database: mariadb + - php: 8.3 + moodle-branch: MOODLE_405_STABLE + database: pgsql steps: - name: Check out repository code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: plugin @@ -107,11 +125,6 @@ jobs: if: ${{ always() }} run: moodle-plugin-ci phplint - - name: PHP Copy/Paste Detector - continue-on-error: true # This step will show errors but will not fail - if: ${{ always() }} - run: moodle-plugin-ci phpcpd - - name: PHP Mess Detector continue-on-error: true # This step will show errors but will not fail if: ${{ always() }} @@ -142,9 +155,8 @@ jobs: run: moodle-plugin-ci grunt --max-lint-warnings 0 - name: PHPUnit tests -# if: ${{ always() }} - if: ${{ matrix.php != 8.2 && matrix.php != 8.1 }} - run: moodle-plugin-ci phpunit --coverage-text + if: ${{ always() }} + run: moodle-plugin-ci phpunit --fail-on-warning - name: Behat features if: ${{ always() }} diff --git a/README.md b/README.md index e25cd74..4be9ab6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # moodle-report_datawarehouse [![Moodle Plugin CI](https://github.com/lucaboesch/moodle-report_datawarehouse/workflows/Moodle%20Plugin%20CI/badge.svg?branch=main)](https://github.com/lucaboesch/moodle-report_datawarehouse/actions?query=workflow%3A%22Moodle+Plugin+CI%22+branch%3Amain) -[![PHP Support](https://img.shields.io/badge/php-7.4_--_8.2-blue)](https://github.com/lucaboesch/moodle-report_datawarehouse/actions) -[![Moodle Support](https://img.shields.io/badge/Moodle-4.1--4.3-blue)](https://github.com/lucaboesch/moodle-report_datawarehouse/actions) +[![PHP Support](https://img.shields.io/badge/php-8.1_--_8.3-blue)](https://github.com/lucaboesch/moodle-report_datawarehouse/actions) +[![Moodle Support](https://img.shields.io/badge/Moodle-4.2--4.5-orange)](https://github.com/lucaboesch/moodle-report_datawarehouse/actions) [![License GPL-3.0](https://img.shields.io/github/license/lucaboesch/moodle-report_datawarehouse?color=lightgrey)](https://github.com/lucaboesch/moodle-report_datawarehouse/blob/main/LICENSE) [![GitHub contributors](https://img.shields.io/github/contributors/lucaboesch/moodle-report_datawarehouse)](https://github.com/lucaboesch/moodle-report_datawarehouseA/graphs/contributors) diff --git a/classes/backend.php b/classes/backend.php index 135eab6..e19d579 100644 --- a/classes/backend.php +++ b/classes/backend.php @@ -98,7 +98,7 @@ protected function validate_backend(string $backend) { * * @return bool */ - public function can_delete() : bool { + public function can_delete(): bool { $result = true; // phpcs:disable diff --git a/classes/backend_controller.php b/classes/backend_controller.php index 3e6847f..d5cc0c3 100644 --- a/classes/backend_controller.php +++ b/classes/backend_controller.php @@ -127,7 +127,7 @@ protected function set_external_page() { * * @return \report_datawarehouse\backend */ - protected function get_instance($id = 0, \stdClass $data = null) { + protected function get_instance($id = 0, ?\stdClass $data = null) { return new backend($id, $data); } @@ -157,7 +157,7 @@ public function get_sorted_backends_list() { * Returns a text for create new record button. * @return string */ - protected function get_create_button_text() : string { + protected function get_create_button_text(): string { return get_string('addbackend', 'report_datawarehouse'); } @@ -168,7 +168,7 @@ protected function get_create_button_text() : string { * * @return \report_datawarehouse\local\form\backend */ - protected function get_form($instance) : \report_datawarehouse\local\form\backend { + protected function get_form($instance): \report_datawarehouse\local\form\backend { global $PAGE; return new \report_datawarehouse\local\form\backend($PAGE->url->out(false), ['persistent' => $instance]); @@ -178,7 +178,7 @@ protected function get_form($instance) : \report_datawarehouse\local\form\backen * View backend heading string. * @return string */ - protected function get_view_heading() : string { + protected function get_view_heading(): string { return get_string('managebackends', 'report_datawarehouse'); } @@ -186,7 +186,7 @@ protected function get_view_heading() : string { * New backend heading string. * @return string */ - protected function get_new_heading() : string { + protected function get_new_heading(): string { return get_string('newbackend', 'report_datawarehouse'); } @@ -194,7 +194,7 @@ protected function get_new_heading() : string { * Edit backend heading string. * @return string */ - protected function get_edit_heading() : string { + protected function get_edit_heading(): string { return get_string('editbackend', 'report_datawarehouse'); } @@ -202,7 +202,7 @@ protected function get_edit_heading() : string { * Returns base URL for the manager. * @return string */ - public static function get_base_url() : string { + public static function get_base_url(): string { return '/report/datawarehouse/backend.php'; } diff --git a/classes/event/backend_created.php b/classes/event/backend_created.php index 84c6837..3513b73 100644 --- a/classes/event/backend_created.php +++ b/classes/event/backend_created.php @@ -45,7 +45,7 @@ class backend_created extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context): base { global $USER; $tid = $backend->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_backends', 'restore' => 'report_datawarehouse_backends']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/backend_deleted.php b/classes/event/backend_deleted.php index 56386b4..cf47b66 100644 --- a/classes/event/backend_deleted.php +++ b/classes/event/backend_deleted.php @@ -45,7 +45,7 @@ class backend_deleted extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(string $id, \context_system $context) : base { + public static function create_strict(string $id, \context_system $context): base { global $USER; return self::create([ @@ -96,7 +96,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_bkends', 'restore' => 'report_datawarehouse_bkends']; } @@ -106,7 +106,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/backend_disabled.php b/classes/event/backend_disabled.php index 092aa08..4eeb83c 100644 --- a/classes/event/backend_disabled.php +++ b/classes/event/backend_disabled.php @@ -45,7 +45,7 @@ class backend_disabled extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context): base { global $USER; $tid = $backend->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_bkends', 'restore' => 'report_datawarehouse_bkends']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/backend_enabled.php b/classes/event/backend_enabled.php index 54ad03c..4746f79 100644 --- a/classes/event/backend_enabled.php +++ b/classes/event/backend_enabled.php @@ -45,7 +45,7 @@ class backend_enabled extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context): base { global $USER; $tid = $backend->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_bkends', 'restore' => 'report_datawarehouse_bkends']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/backend_updated.php b/classes/event/backend_updated.php index a117fe7..26fca27 100644 --- a/classes/event/backend_updated.php +++ b/classes/event/backend_updated.php @@ -37,7 +37,7 @@ class backend_updated extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\backend $backend, \context_system $context): base { global $USER; $tid = $backend->get('id'); @@ -93,7 +93,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_bkends', 'restore' => 'report_datawarehouse_bkends']; } @@ -103,7 +103,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/query_created.php b/classes/event/query_created.php index 65abf3f..1f80cd0 100644 --- a/classes/event/query_created.php +++ b/classes/event/query_created.php @@ -45,7 +45,7 @@ class query_created extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\query $query, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\query $query, \context_system $context): base { global $USER; $tid = $query->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_queries', 'restore' => 'report_datawarehouse_queries']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/query_deleted.php b/classes/event/query_deleted.php index 1254164..9a3a92b 100644 --- a/classes/event/query_deleted.php +++ b/classes/event/query_deleted.php @@ -45,7 +45,7 @@ class query_deleted extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(string $id, \context_system $context) : base { + public static function create_strict(string $id, \context_system $context): base { global $USER; return self::create([ @@ -96,7 +96,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_queries', 'restore' => 'report_datawarehouse_queries']; } @@ -106,7 +106,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/query_disabled.php b/classes/event/query_disabled.php index 3da584f..931360e 100644 --- a/classes/event/query_disabled.php +++ b/classes/event/query_disabled.php @@ -37,7 +37,7 @@ class query_disabled extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\query $query, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\query $query, \context_system $context): base { global $USER; $tid = $query->get('id'); @@ -93,7 +93,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_queries', 'restore' => 'report_datawarehouse_queries']; } @@ -103,7 +103,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/query_enabled.php b/classes/event/query_enabled.php index 03357aa..c96621e 100644 --- a/classes/event/query_enabled.php +++ b/classes/event/query_enabled.php @@ -45,7 +45,7 @@ class query_enabled extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\query $query, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\query $query, \context_system $context): base { global $USER; $tid = $query->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_queries', 'restore' => 'report_datawarehouse_queries']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/query_updated.php b/classes/event/query_updated.php index 90b1c2e..60408ed 100644 --- a/classes/event/query_updated.php +++ b/classes/event/query_updated.php @@ -45,7 +45,7 @@ class query_updated extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\query $query, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\query $query, \context_system $context): base { global $USER; $tid = $query->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_queries', 'restore' => 'report_datawarehouse']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/run_created.php b/classes/event/run_created.php index 12fb170..62fce92 100644 --- a/classes/event/run_created.php +++ b/classes/event/run_created.php @@ -45,7 +45,7 @@ class run_created extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\run $run, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\run $run, \context_system $context): base { global $USER; $tid = $run->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_runs', 'restore' => 'report_datawarehouse_runs']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/run_deleted.php b/classes/event/run_deleted.php index b00f9a6..e6d1db2 100644 --- a/classes/event/run_deleted.php +++ b/classes/event/run_deleted.php @@ -45,7 +45,7 @@ class run_deleted extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(string $id, \context_system $context) : base { + public static function create_strict(string $id, \context_system $context): base { global $USER; return self::create([ @@ -96,7 +96,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_runs', 'restore' => 'report_datawarehouse_runs']; } @@ -106,7 +106,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/run_disabled.php b/classes/event/run_disabled.php index 47b63c4..fd0ed4a 100644 --- a/classes/event/run_disabled.php +++ b/classes/event/run_disabled.php @@ -45,7 +45,7 @@ class run_disabled extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\run $run, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\run $run, \context_system $context): base { global $USER; $tid = $run->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_runs', 'restore' => 'report_datawarehouse_runs']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/run_enabled.php b/classes/event/run_enabled.php index 863feab..2bbbdd6 100644 --- a/classes/event/run_enabled.php +++ b/classes/event/run_enabled.php @@ -45,7 +45,7 @@ class run_enabled extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\run $run, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\run $run, \context_system $context): base { global $USER; $tid = $run->get('id'); @@ -101,7 +101,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_bkends', 'restore' => 'report_datawarehouse_bkends']; } @@ -111,7 +111,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/event/run_updated.php b/classes/event/run_updated.php index b2b4651..b5e9e82 100644 --- a/classes/event/run_updated.php +++ b/classes/event/run_updated.php @@ -37,7 +37,7 @@ class run_updated extends base { * @param \context_system $context Context system. * @return base */ - public static function create_strict(\report_datawarehouse\run $run, \context_system $context) : base { + public static function create_strict(\report_datawarehouse\run $run, \context_system $context): base { global $USER; $tid = $run->get('id'); @@ -93,7 +93,7 @@ public function get_description() { * * @return array Mapping of object id. */ - public static function get_objectid_mapping() : array { + public static function get_objectid_mapping(): array { return ['db' => 'report_datawarehouse_runs', 'restore' => 'report_datawarehouse_runs']; } @@ -103,7 +103,7 @@ public static function get_objectid_mapping() : array { * * @return array List of mapping of other ids. */ - public static function get_other_mapping() : array { + public static function get_other_mapping(): array { return []; } } diff --git a/classes/local/table/backend_list.php b/classes/local/table/backend_list.php index 9f05780..294373a 100644 --- a/classes/local/table/backend_list.php +++ b/classes/local/table/backend_list.php @@ -86,7 +86,7 @@ public function __construct($id = null) { * @param \report_datawarehouse\backend $data Backend for this row. * @return string */ - protected function col_name(backend $data) : string { + protected function col_name(backend $data): string { return \html_writer::link( new \moodle_url(backend_controller::get_base_url(), [ 'id' => $data->get('id'), @@ -102,7 +102,7 @@ protected function col_name(backend $data) : string { * @param \report_datawarehouse\backend $data Backend for this row. * @return string */ - protected function col_description(backend $data) : string { + protected function col_description(backend $data): string { return $data->get('description'); } @@ -132,7 +132,7 @@ protected function col_used(backend $data): string { * @param \report_datawarehouse\backend $data Backend for this row. * @return string */ - protected function col_actions(backend $data) : string { + protected function col_actions(backend $data): string { $actions = []; $actions[] = helper::format_icon_link( diff --git a/classes/local/table/query_list.php b/classes/local/table/query_list.php index b2c80e4..ac62abe 100644 --- a/classes/local/table/query_list.php +++ b/classes/local/table/query_list.php @@ -86,7 +86,7 @@ public function __construct($id = null) { * @param \report_datawarehouse\query $data Query for this row. * @return string */ - protected function col_name(query $data) : string { + protected function col_name(query $data): string { return \html_writer::link( new \moodle_url(query_controller::get_base_url(), [ 'id' => $data->get('id'), @@ -102,7 +102,7 @@ protected function col_name(query $data) : string { * @param \report_datawarehouse\query $data Query for this row. * @return string */ - protected function col_description(query $data) : string { + protected function col_description(query $data): string { return $data->get('description'); } @@ -132,7 +132,7 @@ protected function col_used(query $data): string { * @param \report_datawarehouse\query $data Query for this row. * @return string */ - protected function col_actions(query $data) : string { + protected function col_actions(query $data): string { $actions = []; $actions[] = helper::format_icon_link( diff --git a/classes/local/table/run_list.php b/classes/local/table/run_list.php index 89a2e30..4ac3fbd 100644 --- a/classes/local/table/run_list.php +++ b/classes/local/table/run_list.php @@ -86,7 +86,7 @@ public function __construct($id = null) { * @param \report_datawarehouse\run $data Query for this row. * @return string */ - protected function col_name(run $data) : string { + protected function col_name(run $data): string { return \html_writer::link( new \moodle_url(run_controller::get_base_url(), [ 'id' => $data->get('id'), @@ -102,7 +102,7 @@ protected function col_name(run $data) : string { * @param \report_datawarehouse\run $data Query for this row. * @return string */ - protected function col_description(run $data) : string { + protected function col_description(run $data): string { return $data->get('description'); } @@ -132,7 +132,7 @@ protected function col_used(run $data): string { * @param \report_datawarehouse\run $data Query for this row. * @return string */ - protected function col_actions(run $data) : string { + protected function col_actions(run $data): string { $actions = []; $actions[] = helper::format_icon_link( diff --git a/classes/output/backend_category.php b/classes/output/backend_category.php index 08051d9..1a20859 100644 --- a/classes/output/backend_category.php +++ b/classes/output/backend_category.php @@ -69,7 +69,7 @@ class backend_category implements renderable, templatable { */ public function __construct(\report_datawarehouse\local\backend_category $backendcategory, context $context, bool $expandable = false, int $showbackendcat = 0, int $hidebackendcat = 0, bool $showonlythislink = false, - bool $addnewbackendbtn = true, moodle_url $returnurl = null) { + bool $addnewbackendbtn = true, ?moodle_url $returnurl = null) { $this->backendcategory = $backendcategory; $this->context = $context; $this->expandable = $expandable; diff --git a/classes/output/renderer.php b/classes/output/renderer.php index ecb58d7..50fa6d0 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -41,7 +41,7 @@ class renderer extends plugin_renderer_base { * @throws \coding_exception * @throws \moodle_exception */ - public function render_report_actions(stdClass $report, stdClass $category, context $context):string { + public function render_report_actions(stdClass $report, stdClass $category, context $context): string { if (has_capability('report/customsql:definequeries', $context)) { $reporturl = report_datawarehouse_url('view.php', ['id' => $report->id]); $editaction = $this->action_link( diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 87b2450..f4506b6 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -39,7 +39,7 @@ class provider implements \core_privacy\local\metadata\null_provider { * * @return string */ - public static function get_reason() : string { + public static function get_reason(): string { return 'privacy:metadata'; } } diff --git a/classes/query.php b/classes/query.php index 299466a..164a5bf 100644 --- a/classes/query.php +++ b/classes/query.php @@ -86,7 +86,7 @@ protected function validate_query(string $query) { * * @return bool */ - public function can_delete() : bool { + public function can_delete(): bool { $result = true; // phpcs:disable diff --git a/classes/query_controller.php b/classes/query_controller.php index 9b9eea6..4d562a7 100644 --- a/classes/query_controller.php +++ b/classes/query_controller.php @@ -127,7 +127,7 @@ protected function set_external_page() { * * @return \report_datawarehouse\query */ - protected function get_instance($id = 0, \stdClass $data = null) { + protected function get_instance($id = 0, ?\stdClass $data = null) { return new query($id, $data); } @@ -157,7 +157,7 @@ public function get_sorted_queries_list() { * Returns a text for create new record button. * @return string */ - protected function get_create_button_text() : string { + protected function get_create_button_text(): string { return get_string('addquery', 'report_datawarehouse'); } @@ -168,7 +168,7 @@ protected function get_create_button_text() : string { * * @return \report_datawarehouse\local\form\query */ - protected function get_form($instance) : \report_datawarehouse\local\form\query { + protected function get_form($instance): \report_datawarehouse\local\form\query { global $PAGE; return new \report_datawarehouse\local\form\query($PAGE->url->out(false), ['persistent' => $instance]); @@ -178,7 +178,7 @@ protected function get_form($instance) : \report_datawarehouse\local\form\query * View query heading string. * @return string */ - protected function get_view_heading() : string { + protected function get_view_heading(): string { return get_string('managequeries', 'report_datawarehouse'); } @@ -186,7 +186,7 @@ protected function get_view_heading() : string { * New query heading string. * @return string */ - protected function get_new_heading() : string { + protected function get_new_heading(): string { return get_string('newquery', 'report_datawarehouse'); } @@ -194,7 +194,7 @@ protected function get_new_heading() : string { * Edit query heading string. * @return string */ - protected function get_edit_heading() : string { + protected function get_edit_heading(): string { return get_string('editquery', 'report_datawarehouse'); } @@ -202,7 +202,7 @@ protected function get_edit_heading() : string { * Returns base URL for the manager. * @return string */ - public static function get_base_url() : string { + public static function get_base_url(): string { return '/report/datawarehouse/query.php'; } diff --git a/classes/run.php b/classes/run.php index 73fff71..54594ee 100644 --- a/classes/run.php +++ b/classes/run.php @@ -90,7 +90,7 @@ protected function validate_run(string $run) { * * @return bool */ - public function can_delete() : bool { + public function can_delete(): bool { $result = true; // phpcs:disable diff --git a/classes/run_controller.php b/classes/run_controller.php index 9badc94..255b15a 100644 --- a/classes/run_controller.php +++ b/classes/run_controller.php @@ -139,7 +139,7 @@ protected function set_external_page() { * * @return \report_datawarehouse\run */ - protected function get_instance($id = 0, \stdClass $data = null) { + protected function get_instance($id = 0, ?\stdClass $data = null) { return new run($id, $data); } @@ -170,7 +170,7 @@ public function get_sorted_runs_list() { * Returns a text for create new record button. * @return string */ - protected function get_create_button_text() : string { + protected function get_create_button_text(): string { return get_string('addrun', 'report_datawarehouse'); } @@ -181,7 +181,7 @@ protected function get_create_button_text() : string { * * @return \report_datawarehouse\local\form\run */ - protected function get_form($instance) : \report_datawarehouse\local\form\run { + protected function get_form($instance): \report_datawarehouse\local\form\run { global $PAGE; return new \report_datawarehouse\local\form\run($PAGE->url->out(false), ['persistent' => $instance]); @@ -191,7 +191,7 @@ protected function get_form($instance) : \report_datawarehouse\local\form\run { * View run heading string. * @return string */ - protected function get_view_heading() : string { + protected function get_view_heading(): string { return get_string('manageruns', 'report_datawarehouse'); } @@ -199,7 +199,7 @@ protected function get_view_heading() : string { * New run heading string. * @return string */ - protected function get_new_heading() : string { + protected function get_new_heading(): string { return get_string('newrun', 'report_datawarehouse'); } @@ -207,7 +207,7 @@ protected function get_new_heading() : string { * Edit run heading string. * @return string */ - protected function get_edit_heading() : string { + protected function get_edit_heading(): string { return get_string('editrun', 'report_datawarehouse'); } @@ -215,7 +215,7 @@ protected function get_edit_heading() : string { * Returns base URL for the manager. * @return string */ - public static function get_base_url() : string { + public static function get_base_url(): string { return '/report/datawarehouse/run.php'; } diff --git a/lang/en/report_datawarehouse.php b/lang/en/report_datawarehouse.php index 3789b20..44b65bb 100644 --- a/lang/en/report_datawarehouse.php +++ b/lang/en/report_datawarehouse.php @@ -40,10 +40,10 @@ $string['canteditrun'] = 'The run can\'t be edited.'; $string['categorycontent'] = '({$a->manual} on-demand, {$a->daily} daily, {$a->weekly} weekly, {$a->monthly} monthly)'; $string['confirmbackendremovalquestion'] = 'Are you sure you want to remove this backend?'; -$string['confirmqueryremovalquestion'] = 'Are you sure you want to remove this query?'; -$string['confirmrunremovalquestion'] = 'Are you sure you want to remove this run?'; $string['confirmbackendremovaltitle'] = 'Confirm backend removal?'; +$string['confirmqueryremovalquestion'] = 'Are you sure you want to remove this query?'; $string['confirmqueryremovaltitle'] = 'Confirm query removal?'; +$string['confirmrunremovalquestion'] = 'Are you sure you want to remove this run?'; $string['confirmrunremovaltitle'] = 'Confirm run removal?'; $string['courseid'] = 'Course ID'; $string['coursemoduleid'] = 'Course module ID'; @@ -56,6 +56,7 @@ $string['editbackend'] = 'Edit backend'; $string['editquery'] = 'Edit query'; $string['editrun'] = 'Edit run'; +$string['enabled'] = 'Enabled'; $string['event:backendcreated'] = 'Data warehouse report backend was created'; $string['event:backenddeleted'] = 'Data warehouse report backend was deleted'; $string['event:backenddisabled'] = 'Data warehouse report backend was disabled'; @@ -71,17 +72,16 @@ $string['event:rundisabled'] = 'Data warehouse report run was disabled'; $string['event:runenabled'] = 'Data warehouse report run was enabled'; $string['event:runupdated'] = 'Data warehouse report run was updated'; -$string['enabled'] = 'Enabled'; $string['lastrun'] = 'Last run'; $string['name'] = 'Name'; -$string['note'] = 'Notes'; -$string['nobackendsavailable'] = 'No backends available'; -$string['noqueriesavailable'] = 'No queries available'; -$string['norunsavailable'] = 'No runs available'; $string['namerequired'] = 'A name is required'; $string['newbackend'] = 'New backend'; $string['newquery'] = 'New query'; $string['newrun'] = 'New run'; +$string['nobackendsavailable'] = 'No backends available'; +$string['noqueriesavailable'] = 'No queries available'; +$string['norunsavailable'] = 'No runs available'; +$string['note'] = 'Notes'; $string['password'] = 'Password'; $string['pluginname'] = 'Data warehouse reports'; $string['query'] = 'Query'; diff --git a/locallib.php b/locallib.php index ddaec0b..a36666a 100644 --- a/locallib.php +++ b/locallib.php @@ -856,7 +856,7 @@ function report_datawarehouse_get_month_starts($timenow) { * @param string $itemid The item id * @throws coding_exception */ -function report_datawarehouse_get_filename(int $cmid, stdClass $query, string $itemid) :string { +function report_datawarehouse_get_filename(int $cmid, stdClass $query, string $itemid): string { global $USER; $timezone = \core_date::get_user_timezone_object(); $timestamp = time(); @@ -1320,7 +1320,7 @@ function report_datawarehouse_sort_reports_by_displayname(array $records): array * @return int the highest itemid * @throws dml_exception */ -function get_file_itemid() :int { +function get_file_itemid(): int { global $DB; $highestitemid = $DB->get_field_sql("SELECT max(itemid) FROM {files} WHERE component = 'report_datawarehouse' AND filearea = 'data'"); @@ -1337,7 +1337,7 @@ function get_file_itemid() :int { * @throws file_exception * @throws stored_file_creation_exception */ -function write_datawarehouse_file($filerecord, $content) :bool { +function write_datawarehouse_file($filerecord, $content): bool { $fs = get_file_storage(); // Create a file and save it. if (($fs->create_file_from_string($filerecord, $content)) != null) { diff --git a/tests/file_storage_test.php b/tests/file_storage_test.php index 16c37e6..9da3dcf 100644 --- a/tests/file_storage_test.php +++ b/tests/file_storage_test.php @@ -44,7 +44,7 @@ * @copyright 2023 Luca Bösch * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class file_storage_test extends externallib_advanced_testcase { +final class file_storage_test extends externallib_advanced_testcase { /** * Tests saving and retrieving in the file area. @@ -53,9 +53,8 @@ class file_storage_test extends externallib_advanced_testcase { * @runInSeparateProcess * @return void */ - public function test_file_area() { + public function test_file_area(): void { global $DB, $CFG; - require_once($CFG->libdir . '/externallib.php'); $this->resetAfterTest(); $this->setAdminUser(); @@ -88,22 +87,35 @@ public function test_file_area() { $this->assertEquals(1, count($files)); // Now retrieve it. - $expectedfiles[] = [ - 'filename' => 'file.txt', - 'filepath' => '/', - 'fileurl' => "{$CFG->wwwroot}/webservice/pluginfile.php/{$context}/{$component}/{$filearea}/{$newitemid}/file.txt", - 'timemodified' => $timemodified, - 'filesize' => $filesize, - 'mimetype' => 'text/plain', - 'isexternalfile' => false, - ]; + if ($CFG->version < 2023101000) { + $expectedfiles[] = [ + 'filename' => 'file.txt', + 'filepath' => '/', + 'fileurl' => "{$CFG->wwwroot}/webservice/pluginfile.php/{$context}/{$component}/{$filearea}/{$newitemid}/file.txt", + 'timemodified' => (string) $timemodified, + 'filesize' => (string) $filesize, + 'mimetype' => 'text/plain', + 'isexternalfile' => false, + ]; + } else { + $expectedfiles[] = [ + 'filename' => 'file.txt', + 'filepath' => '/', + 'fileurl' => "{$CFG->wwwroot}/webservice/pluginfile.php/{$context}/{$component}/{$filearea}/{$newitemid}/file.txt", + 'timemodified' => (string) $timemodified, + 'filesize' => (string) $filesize, + 'mimetype' => 'text/plain', + 'isexternalfile' => false, + 'icon' => 'f/text', + ]; + } // Get all the files for the area. - $files = \external_util::get_area_files($context, $component, $filearea, false); + $files = \core_external\util::get_area_files($context, $component, $filearea, false); $this->assertEquals($expectedfiles, $files); // Get just the file indicated by $itemid. - $files = \external_util::get_area_files($context, $component, $filearea, $newitemid); + $files = \core_external\util::get_area_files($context, $component, $filearea, $newitemid); $this->assertEquals($expectedfiles, $files); } } diff --git a/version.php b/version.php index ad3dfe9..70f20cd 100644 --- a/version.php +++ b/version.php @@ -26,8 +26,8 @@ $plugin->component = 'report_datawarehouse'; $plugin->release = '0.9.1'; -$plugin->version = 2023112100; +$plugin->version = 2024101200; $plugin->requires = 2022112800; $plugin->maturity = MATURITY_BETA; -$plugin->supported = [401, 403]; -$plugin->release = 'v4.3-r1'; +$plugin->supported = [402, 405]; +$plugin->release = 'v4.5-r1';