summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-05-08 19:18:38 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-05-08 19:18:38 +0200
commit4977a733b6f614de868fc405b820d5c66e5bf9b7 (patch)
treefb033d693061bc22d069aa591e9dadf94c2a54b2
parent22397366614e9d80eed49d28994c5801e8821d27 (diff)
downloadgigologadmin-4977a733b6f614de868fc405b820d5c66e5bf9b7.tar.gz
gigologadmin-4977a733b6f614de868fc405b820d5c66e5bf9b7.tar.bz2
gigologadmin-4977a733b6f614de868fc405b820d5c66e5bf9b7.zip
Auto fixup missing return types by Psalm
-rw-r--r--generate-sample-gig-data.php9
-rw-r--r--giglogadmin.php12
-rw-r--r--includes/admin/helpfiles/instr_photog.php2
-rw-r--r--includes/admin/helpfiles/instr_reviewers.php2
-rw-r--r--includes/admin/helpfiles/instrunctions.php2
-rw-r--r--includes/admin/register_db_tables.php5
-rw-r--r--includes/admin/views/giglog_admin_page.php26
-rw-r--r--includes/admin/views/giglog_import_gigs.php8
-rw-r--r--includes/band.php9
-rw-r--r--includes/concert.php7
-rw-r--r--includes/concertlogs.php4
-rw-r--r--includes/public/shortcodes/giglog_bands.php4
-rw-r--r--includes/public/shortcodes/giglog_display_unprocessed.php6
-rw-r--r--includes/public/shortcodes/giglog_photographers.php16
-rw-r--r--includes/public/shortcodes/giglog_process_files.php2
-rw-r--r--includes/venue.php20
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 {
?>
<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($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($cid, $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 =
@@ -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($concert_id): string
{
global $wpdb;
$query = "SELECT id,wpgs_name from wpg_pressstatus" ;
@@ -192,6 +192,9 @@ 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
+ /**
+ * @return null|string
+ */
static function getpublishstatus($concert_id)
{
global $wpdb;
@@ -209,7 +212,7 @@ 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;
@@ -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($p1, $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..badd678 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,10 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) {
* 5. Event info link
*
* Empty lines are ignored.
+ *
+ * @return void
*/
- static function process_upload($file) {
+ static function process_upload($file): void {
$newconcert= [];
$fo = new SplFileObject($file['tmp_name']);
diff --git a/includes/band.php b/includes/band.php
index 14daa18..81b275a 100644
--- a/includes/band.php
+++ b/includes/band.php
@@ -46,7 +46,7 @@ if ( !class_exists('GiglogAdmin_Band') ) {
return $band;
}
- static function find($name, $country)
+ static function find($name, $country): ?self
{
global $wpdb;
@@ -83,6 +83,11 @@ if ( !class_exists('GiglogAdmin_Band') ) {
return ($results);
}
+ /**
+ * @return array|string
+ *
+ * @psalm-return array{0: mixed, 1: mixed}|string
+ */
static function get_band($bid)
{
global $wpdb;
@@ -116,7 +121,7 @@ if ( !class_exists('GiglogAdmin_Band') ) {
return ($wpdb->last_error);
}
- public function save()
+ public function save(): void
{
global $wpdb;
diff --git a/includes/concert.php b/includes/concert.php
index d95934e..f19a614 100644
--- a/includes/concert.php
+++ b/includes/concert.php
@@ -32,6 +32,9 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
}
+ /**
+ * @return null|self
+ */
static function find_cid($id)
{
global $wpdb;
@@ -51,7 +54,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
}
}
- public static function create($name, $venue, $date, $ticketlink, $eventlink)
+ public static function create($name, $venue, $date, $ticketlink, $eventlink): ?self
{
if ( GiglogAdmin_Concert::find($name, $venue, $date) ) {
error_log( 'DUPLICATE ROW detected: '
@@ -155,7 +158,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) {
return $wpdb->get_results($sql);
}
- public function save()
+ public function save(): void
{
global $wpdb;
diff --git a/includes/concertlogs.php b/includes/concertlogs.php
index 409a454..3b8083a 100644
--- a/includes/concertlogs.php
+++ b/includes/concertlogs.php
@@ -12,8 +12,10 @@ if ( !class_exists( 'GiglogAdmin_Concertlogs' ) )
/**
* Adds a default entry for the given concert id in the
* concert logs table.
+ *
+ * @return void
*/
- public static function add($concert_id)
+ public static function add($concert_id): void
{
global $wpdb;
diff --git a/includes/public/shortcodes/giglog_bands.php b/includes/public/shortcodes/giglog_bands.php
index 78fd72b..e4fe71d 100644
--- a/includes/public/shortcodes/giglog_bands.php
+++ b/includes/public/shortcodes/giglog_bands.php
@@ -10,7 +10,7 @@
* builds the table with concerts
*/
-function giglogadmin_getfilters()
+function giglogadmin_getfilters(): string
{
global $wpdb;
@@ -59,7 +59,7 @@ function giglogadmin_getfilters()
}
-function giglogadmin_getconcerts()
+function giglogadmin_getconcerts(): string
{
global $wpdb;
// Shortcodes RETURN content, so store in a variable to return
diff --git a/includes/public/shortcodes/giglog_display_unprocessed.php b/includes/public/shortcodes/giglog_display_unprocessed.php
index aa3596c..90ef69f 100644
--- a/includes/public/shortcodes/giglog_display_unprocessed.php
+++ b/includes/public/shortcodes/giglog_display_unprocessed.php
@@ -16,7 +16,7 @@
* gone through the processing process - aka fetching each line and
* transforming it into a concert line
*/
-function giglogadmin_getunprocessed()
+function giglogadmin_getunprocessed(): string
{
global $wpdb;
@@ -42,7 +42,7 @@ function giglogadmin_getunprocessed()
* venue exists. If they don't, they get created, if they do, their ID from
* their table is fetchd and used in concerts table
*/
-function giglogadmin_insertconcerts()
+function giglogadmin_insertconcerts(): string
{
global $wpdb;
$concertlist = '<p>Inserted the following:</p>';
@@ -128,7 +128,7 @@ function giglogadmin_insertconcerts()
return $concertlist;
}
-function giglogadmin_display_unprocessed() {
+function giglogadmin_display_unprocessed(): string {
$output = giglogadmin_getunprocessed();
$output .= '<form method="POST" action=""><input type="submit" name="ProcessConcerts" value="ProcessConcerts"/></form>';
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<array-key, self>
+ */
+ 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<array-key, self>
+ */
+ 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;