diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-05-08 21:03:29 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-05-08 21:03:29 +0200 |
commit | 7d17f220e52d683f849a1854278a9bd47af17dd2 (patch) | |
tree | 3fed3ff2c6ab28c397a929a02e56d238ca40ed6d /includes/admin | |
parent | ee9bef751805ac3f3c9572d1620f2221092b3094 (diff) | |
parent | 30f12e61317d9b181efb46382a4db98d73f65954 (diff) | |
download | gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.tar.gz gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.tar.bz2 gigologadmin-7d17f220e52d683f849a1854278a9bd47af17dd2.zip |
Merge branch 'psalm' into dev
This brings another tool in to help us keep the code in order - Psalm.
(I thought the name was fitting! :)
This will do fairly simple static analysis of the code, and report
problems and suggest fixes. It can help fix some issues itself, but
please double check that it does the right thing.
More info: https://psalm.dev
This merge also brings in fixes that was suggested by Paslm. Mostly this
is typa annotations for functions, but also some bugfixes discovered by
the tool.
Diffstat (limited to 'includes/admin')
-rw-r--r-- | includes/admin/helpfiles/instr_photog.php | 2 | ||||
-rw-r--r-- | includes/admin/helpfiles/instr_reviewers.php | 2 | ||||
-rw-r--r-- | includes/admin/helpfiles/instrunctions.php | 2 | ||||
-rw-r--r-- | includes/admin/register_db_tables.php | 5 | ||||
-rw-r--r-- | includes/admin/views/giglog_admin_page.php | 32 | ||||
-rw-r--r-- | includes/admin/views/giglog_import_gigs.php | 10 |
6 files changed, 33 insertions, 20 deletions
diff --git a/includes/admin/helpfiles/instr_photog.php b/includes/admin/helpfiles/instr_photog.php index 0750557..f661c5f 100644 --- a/includes/admin/helpfiles/instr_photog.php +++ b/includes/admin/helpfiles/instr_photog.php @@ -13,7 +13,7 @@ if ( !class_exists( 'Instructions_Photogs' ) ) { - static function render_instr_photo_html() { + static function render_instr_photo_html(): void { diff --git a/includes/admin/helpfiles/instr_reviewers.php b/includes/admin/helpfiles/instr_reviewers.php index e00a432..3632980 100644 --- a/includes/admin/helpfiles/instr_reviewers.php +++ b/includes/admin/helpfiles/instr_reviewers.php @@ -9,7 +9,7 @@ if ( !class_exists( 'Instructions_Reviewers' ) ) { class Instructions_Reviewers { - static function render_instr_rev_html() { + static function render_instr_rev_html(): void { ?> diff --git a/includes/admin/helpfiles/instrunctions.php b/includes/admin/helpfiles/instrunctions.php index 49b77fe..b9c4d89 100644 --- a/includes/admin/helpfiles/instrunctions.php +++ b/includes/admin/helpfiles/instrunctions.php @@ -9,7 +9,7 @@ if ( !class_exists( 'Instructions_Page' ) ) { class Instructions_Page { - static function render_instr_html() { + static function render_instr_html(): void { ?> diff --git a/includes/admin/register_db_tables.php b/includes/admin/register_db_tables.php index 947be22..11223b3 100644 --- a/includes/admin/register_db_tables.php +++ b/includes/admin/register_db_tables.php @@ -5,7 +5,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later if (!function_exists('giglogadmin_populate_countries')) { - function giglogadmin_populate_countries() + function giglogadmin_populate_countries(): void { global $wpdb; $wpdb->query( @@ -254,6 +254,9 @@ if (!function_exists('giglogadmin_populate_countries')) { if ( !function_exists( "giglog_register_db_tables") ) { + /** + * @return void + */ function giglog_register_db_tables() { $db_version = get_option('giglogadmin_db_version'); diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 72a34eb..624566f 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -9,7 +9,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { require_once __DIR__ . '/../../venue.php'; class GiglogAdmin_AdminPage { - static function render_html() { + static function render_html(): void { ?> <div class="wrap"> <h1>Giglog Admin</h1> @@ -36,7 +36,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { echo(GiglogAdmin_AdminPage::editforms()); //not sure why it doesn't show without the echo? } - static function get_allvenues($invenue) + static function get_allvenues( ?int $invenue ): string { $select = '<select name="selectvenueadmin">'; $select .= '<option value="">Please Select..</option>'; @@ -50,7 +50,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_user($cid, $ctype) + static function get_user( ?int $cid, string $ctype): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; @@ -75,7 +75,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_filters() + static function get_filters(): string { $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities()); $selected_city = @@ -107,7 +107,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $select .= '<select name="selectvenue">'; - foreach ( $venues AS $venue ) { + foreach ( $venue_list as $venue ) { $select .= '<option value="' . $venue[0] . '"' . selected($venue, $selected_venue) . '>'; $select .= $venue[1] . '</option>'; } @@ -124,7 +124,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $select; } - static function editforms() + static function editforms(): string { $cid = filter_input(INPUT_POST, "cid"); $editing = filter_input(INPUT_POST, "edit") == "EDIT"; @@ -167,7 +167,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $content; } - static function adminactions($concert_id) + static function adminactions( int $concert_id ) : string { global $wpdb; $query = "SELECT id,wpgs_name from wpg_pressstatus" ; @@ -192,7 +192,10 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } //function to calculate if the concert has been added in the past 10 days or before that and show a green NEW for the newest rows - static function getpublishstatus($concert_id) + /** + * @return null|string + */ + static function getpublishstatus(int $concert_id) { global $wpdb; $date1 = new DateTime("now"); @@ -209,11 +212,11 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_concerts() + static function get_concerts(): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; - $roles = ( array ) $hf_user->roles; + $roles = $hf_user->roles; global $wpdb; $content = '<table class="assignit">'; @@ -292,6 +295,9 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } + /** + * @return void + */ static function update() { global $wpdb; @@ -371,7 +377,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } } - static function assignconcert($p1, $c) + static function assignconcert($p1, $c): void { global $wpdb; @@ -392,7 +398,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { wp_mail( $to, $subject, $body, $headers ); } - static function unassignconcert($p1, $c) + static function unassignconcert($p1, $c): void { global $wpdb; @@ -413,7 +419,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { wp_mail( $to, $subject, $body, $headers ); } - static function returnuser($p1, $c) + static function returnuser(string $p1, ?int $c): string { global $wpdb; $hf_user = wp_get_current_user(); diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php index 053f505..0e7406f 100644 --- a/includes/admin/views/giglog_import_gigs.php +++ b/includes/admin/views/giglog_import_gigs.php @@ -12,7 +12,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { require_once __DIR__ . '/../../venue.php'; class GiglogAdmin_ImportGigsPage { - static function render_html() { + static function render_html(): void { ?> <div class="wrap"> <h1>Import gigs</h1> @@ -27,7 +27,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { <?php } - static function submit_form() { + static function submit_form(): void { if ('POST' === $_SERVER['REQUEST_METHOD'] && current_user_can('upload_files') && !empty($_FILES['giglog_import_file']['tmp_name'])) { $nonce = $_POST['giglog_import_nonce']; $valid_nonce = isset($nonce) && wp_verify_nonce($nonce); @@ -48,8 +48,12 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { * 5. Event info link * * Empty lines are ignored. + * + * @return void + * + * @param ArrayAccess|array $file */ - static function process_upload($file) { + static function process_upload(array $file): void { $newconcert= []; $fo = new SplFileObject($file['tmp_name']); |