From 4977a733b6f614de868fc405b820d5c66e5bf9b7 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 8 May 2021 19:18:38 +0200 Subject: Auto fixup missing return types by Psalm --- includes/admin/helpfiles/instr_photog.php | 2 +- includes/admin/helpfiles/instr_reviewers.php | 2 +- includes/admin/helpfiles/instrunctions.php | 2 +- includes/admin/register_db_tables.php | 5 ++++- includes/admin/views/giglog_admin_page.php | 26 ++++++++++++++++---------- includes/admin/views/giglog_import_gigs.php | 8 +++++--- 6 files changed, 28 insertions(+), 17 deletions(-) (limited to 'includes/admin') 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..f2b6edd 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 { ?>

Giglog Admin

@@ -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($invenue): string { $select = ''; $select .= ''; @@ -50,7 +50,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_user($cid, $ctype): string + static function get_user( int $cid, int $ctype): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; @@ -107,7 +107,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $select .= ''; $select .= ''; @@ -50,7 +50,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { } - static function get_user( int $cid, int $ctype): string + static function get_user( ?int $cid, string $ctype): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; @@ -419,7 +419,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { wp_mail( $to, $subject, $body, $headers ); } - static function returnuser($p1, $c): string + 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 badd678..0e7406f 100644 --- a/includes/admin/views/giglog_import_gigs.php +++ b/includes/admin/views/giglog_import_gigs.php @@ -50,8 +50,10 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { * Empty lines are ignored. * * @return void + * + * @param ArrayAccess|array $file */ - static function process_upload($file): void { + static function process_upload(array $file): void { $newconcert= []; $fo = new SplFileObject($file['tmp_name']); -- cgit v1.2.3 From d116e23de0efcd528226acf6dbe4c7cbc5c5698b Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 May 2021 15:42:58 +0200 Subject: Include info from venue in concerts. This makes the concert a full object containing all relevant info, while we can still segment the data in the db. Instead of this: $concert = GiglogAdmin_Concert::get($concert_id); $venue = GiglogAdmin_Venue::get($concert->venue()); echo "{$concert->name()} @ {$venue->name()} : {$concert->cdate()}" You can now do: $concert = GiglogAdmin_Concert::get($concert_id); echo "{$concert->name()} @ {$concert->venue()->name()} : {$concert->cdate()}" And yeah, renamed Concert::find_cid() to Concert::get() and changed it's semantics somewhat. It now either returns the given concert if it exists, or NULL if it does not. Simpler function; simpler to use. --- includes/admin/views/giglog_admin_page.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index b78b4db..2971a22 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -36,13 +36,17 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { echo(GiglogAdmin_AdminPage::editforms()); //not sure why it doesn't show without the echo? } - static function get_allvenues( ?int $invenue ): string + static function get_allvenues( ?GiglogAdmin_Venue $invenue ): string { $select = ''; @@ -131,7 +135,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $editing = filter_input(INPUT_POST, "edit") == "EDIT"; if ($editing && !empty($cid)) //A bit overdoing with the checks if concert ID is empty both here and in find_cid. But based on that, things are NULL or not. Better ideas? - $c = GiglogAdmin_Concert::find_cid($cid); + $c = GiglogAdmin_Concert::get($cid); else $c = new GiglogAdmin_Concert(); @@ -140,7 +144,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { .'
CONCERT DETAILS

' .'' .'
' - .''.GiglogAdmin_AdminPage::get_allvenues($c->venue()).'
' + .'' . GiglogAdmin_AdminPage::get_allvenues($c->venue()) . '
' .'
' .'
' .'
' -- cgit v1.2.3 From b58211e3617f4125567c313736f5ed0bcea7313c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 May 2021 15:51:37 +0200 Subject: Rename strangely named function. GoglogAdmin_AdminPage::get_allvenues did not get all venues, but presented a selection control for selecting a venue. Renamed it as get_venue_selector instead. --- includes/admin/views/giglog_admin_page.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 2971a22..9d9d759 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -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( ?GiglogAdmin_Venue $invenue ): string + static function get_venue_selector( ?GiglogAdmin_Venue $invenue ): string { $select = '' .'
' - .'' . GiglogAdmin_AdminPage::get_allvenues($c->venue()) . '
' + .'' . GiglogAdmin_AdminPage::get_venue_selector($c->venue()) . '
' .'
' .'
' .'
' -- cgit v1.2.3 From 142ff436282844677b8b4e7d8ececd44440ec96d Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 May 2021 17:24:12 +0200 Subject: Fix importing gigs after changes to the concert class. --- includes/admin/views/giglog_import_gigs.php | 30 ++++++++++------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'includes/admin') diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php index 0e7406f..a8daa3f 100644 --- a/includes/admin/views/giglog_import_gigs.php +++ b/includes/admin/views/giglog_import_gigs.php @@ -42,7 +42,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { * tab character: * * 1. Concertname - * 2. Venuename + * 2. Venuename or numeric venue id * 3. Concert date * 4. Ticket link * 5. Event info link @@ -65,31 +65,21 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { } $resultArray = explode("\t", $line); - $cname = trim($resultArray[0]); + $cname = trim($resultArray[0]); $venue = trim($resultArray[1]); - $condate = date('Y-m-d', strtotime($resultArray[2])); - $ticketlink = trim($resultArray[3]); - $eventlink = trim($resultArray[4]); - //first item in the row should be concert name $resultArray[0]; second should be venue $resultArray[1]; third should be concert date $resultArray[2]; - //fourth item is ticketlink $resultArray[3]; fifth item is eventlink $resultArray[4]; - - - if (is_numeric($venue)) - $newconcert[1] = $venue; + if (is_numeric($venue)) { + $venue = GiglogAdmin_Venue::get($venue); + } else { - $v = GiglogAdmin_Venue::find_or_create($venue,'Oslo'); //phase 666 of the project should maybe consider both city and band country when creating concerts/importing files - $newconcert[1] = $v->id(); + $venue = GiglogAdmin_Venue::find_or_create($venue,'Oslo'); } - //not sure how to check dates, hopefully manual verification of files will take care of it + $condate = date('Y-m-d', strtotime($resultArray[2])); + $ticketlink = trim($resultArray[3]); + $eventlink = trim($resultArray[4]); - GiglogAdmin_Concert::create( - $cname, - $newconcert[1], - $condate, - $ticketlink, - $eventlink); + GiglogAdmin_Concert::create($cname, $venue->id(), $condate, $ticketlink, $eventlink); } } } -- cgit v1.2.3