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 --- generate-sample-gig-data.php | 9 ++++++++ giglogadmin.php | 12 +++++----- 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 ++++--- includes/band.php | 9 ++++++-- includes/concert.php | 7 ++++-- includes/concertlogs.php | 4 +++- includes/public/shortcodes/giglog_bands.php | 4 ++-- .../shortcodes/giglog_display_unprocessed.php | 6 ++--- .../public/shortcodes/giglog_photographers.php | 16 ++++++++----- .../public/shortcodes/giglog_process_files.php | 2 +- includes/venue.php | 20 ++++++++++++----- 16 files changed, 91 insertions(+), 43 deletions(-) diff --git a/generate-sample-gig-data.php b/generate-sample-gig-data.php index 26ba0cf..bbc3e7d 100644 --- a/generate-sample-gig-data.php +++ b/generate-sample-gig-data.php @@ -51,6 +51,9 @@ class BandNameGenerator extends GeneratorBase "ed", ); + /** + * @return string + */ public function get() { $parts = array( @@ -91,6 +94,9 @@ class VenueGenerator extends GeneratorBase "lighthouse" ); + /** + * @return string + */ public function get() { $parts = array( @@ -104,6 +110,9 @@ class VenueGenerator extends GeneratorBase class LinkGenerator extends GeneratorBase { + /** + * @return string + */ public function get() { return 'https://example.com/' . bin2hex(random_bytes(8)); diff --git a/giglogadmin.php b/giglogadmin.php index 0e8b399..d71496b 100644 --- a/giglogadmin.php +++ b/giglogadmin.php @@ -36,7 +36,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { class GiglogAdmin_Plugin { - static public function init() { + static public function init(): void { add_shortcode('giglog_cities', 'giglogadmin_getfilters'); add_shortcode('giglog_bands', 'giglogadmin_getconcerts'); add_shortcode('giglog_unprocessed', 'giglogadmin_display_unprocessed'); @@ -49,18 +49,20 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { add_filter( 'wp_nav_menu_args', array( 'GiglogAdmin_Plugin', 'nav_menu_args' )); } - static function activate() { + static function activate(): void { require_once __DIR__ . '/includes/admin/register_db_tables.php'; } - static function deactivate() { + static function deactivate(): void { } /** * Adds the 'Giglog' top level menu to the left side WordPress admin * menu. Other subpages will come later. + * + * @return void */ - static function add_admin_pages() { + static function add_admin_pages(): void { $top = add_menu_page( "Giglog admin", // Page title "Giglog", // Menu title @@ -86,7 +88,7 @@ if ( !class_exists( 'GiglogAdmin_Plugin' ) ) { wp_enqueue_style('css_style'); } - static function add_help_pages() { + static function add_help_pages(): void { add_menu_page( "Help for ET users", // Page title "Help for ET users", // Menu title 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 = ''; diff --git a/includes/public/shortcodes/giglog_photographers.php b/includes/public/shortcodes/giglog_photographers.php index 500445a..829c53e 100644 --- a/includes/public/shortcodes/giglog_photographers.php +++ b/includes/public/shortcodes/giglog_photographers.php @@ -10,7 +10,7 @@ * Admin users also control concert statuses here */ -function giglogadmin_assignconcert($p1, $c) +function giglogadmin_assignconcert($p1, $c): void { global $wpdb; @@ -40,7 +40,7 @@ function giglogadmin_assignconcert($p1, $c) } -function giglogadmin_unassignconcert($p1, $c) +function giglogadmin_unassignconcert($p1, $c): void { global $wpdb; @@ -71,6 +71,9 @@ function giglogadmin_unassignconcert($p1, $c) } +/** + * @return null|string + */ function giglogadmin_getpublishstatus ($c) { global $wpdb; @@ -88,6 +91,9 @@ function giglogadmin_getpublishstatus ($c) } +/** + * @return null|string + */ function giglogadmin_returnuser($p1, $c) { global $wpdb; @@ -164,7 +170,7 @@ function giglogadmin_returnuser($p1, $c) } -function giglogadmin_getfiltersphotog() { +function giglogadmin_getfiltersphotog(): string { global $wpdb; //echo (var_dump($_POST["selectvenue"])); @@ -211,7 +217,7 @@ function giglogadmin_getfiltersphotog() { } -function giglogadmin_getconcertsphotog ( ) { +function giglogadmin_getconcertsphotog ( ): string { $hf_user = wp_get_current_user(); $hf_username = $hf_user->user_login; $roles = ( array ) $hf_user->roles; @@ -370,7 +376,7 @@ function giglogadmin_getconcertsphotog ( ) { return $content; } -function giglogadmin_photographers() +function giglogadmin_photographers(): string { $output = giglogadmin_getfiltersphotog(); $output .= giglogadmin_getconcertsphotog(); diff --git a/includes/public/shortcodes/giglog_process_files.php b/includes/public/shortcodes/giglog_process_files.php index 9dc2ec0..9443cda 100644 --- a/includes/public/shortcodes/giglog_process_files.php +++ b/includes/public/shortcodes/giglog_process_files.php @@ -9,7 +9,7 @@ * Band Venue Date TicketLink Eventlink. The form is at the end of this snippet */ -function giglogadmin_upload_files() { +function giglogadmin_upload_files(): string { global $wpdb; $output = ""; $dir = wp_upload_dir()['basedir'].'/concertlists/'; //the basedir is from file uploader plugin, namely the uploads folder in which I created a concertlist folder diff --git a/includes/venue.php b/includes/venue.php index f6f46b2..ddd3d4a 100644 --- a/includes/venue.php +++ b/includes/venue.php @@ -28,7 +28,7 @@ if ( !class_exists('GiglogAdmin_Venue') ) { $this->webpage = isset($attrs->wpgvenue_webpage) ? $attrs->wpgvenue_webpage : NULL; } - static function create($name, $city = 'Oslo') + static function create($name, $city = 'Oslo'): self { $venue = new GiglogAdmin_Venue((object) [ 'wpgvenue_name' => $name, @@ -61,7 +61,7 @@ if ( !class_exists('GiglogAdmin_Venue') ) { } } - static function all_cities() + static function all_cities(): array { global $wpdb; $results = $wpdb->get_results('select distinct wpgvenue_city from wpg_venues'); @@ -69,7 +69,12 @@ if ( !class_exists('GiglogAdmin_Venue') ) { return array_map(function ($r) { return $r->wpgvenue_city; }, $results); } - static function all_venues() + /** + * @return self[] + * + * @psalm-return array + */ + static function all_venues(): array { global $wpdb; @@ -79,7 +84,12 @@ if ( !class_exists('GiglogAdmin_Venue') ) { } - static function venues_in_city($city) + /** + * @return self[] + * + * @psalm-return array + */ + static function venues_in_city($city): array { global $wpdb; $q = $wpdb->prepare( @@ -89,7 +99,7 @@ if ( !class_exists('GiglogAdmin_Venue') ) { return array_map(function ($r) { return new GiglogAdmin_Venue($r); }, $results); } - public function save() + public function save(): void { global $wpdb; -- cgit v1.2.3