From 3668e685566bed2d3623a3cd276d93f79319a008 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Thu, 2 Sep 2021 09:10:19 +0200 Subject: psalm: Add type info to attrs and constructor for Concert. Also make sure we explicitly set the venue attribute in the constructor. --- includes/concert.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'includes/concert.php') diff --git a/includes/concert.php b/includes/concert.php index 53cd00e..cc1efaa 100644 --- a/includes/concert.php +++ b/includes/concert.php @@ -5,17 +5,19 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +require_once __DIR__ . '/venue.php'; + if ( !class_exists('GiglogAdmin_Concert') ) { require_once __DIR__ . '/venue.php'; class GiglogAdmin_Concert { - private $id; - private $cname; - private $venue; - private $cdate; - private $tickets; - private $eventlink; + private int $id; + private string $cname; + private ?GiglogAdmin_Venue $venue; + private string $cdate; + private string $tickets; + private string $eventlink; private int $status; private array $roles; @@ -32,7 +34,7 @@ if ( !class_exists('GiglogAdmin_Concert') ) { * so this constructor can be used to construct the object * directly from the database row. */ - public function __construct($attrs = []) + public function __construct(object $attrs) { $this->id = isset($attrs->id) ? $attrs->id : NULL; $this->cname = isset($attrs->wpgconcert_name) ? $attrs->wpgconcert_name : NULL; @@ -56,6 +58,9 @@ if ( !class_exists('GiglogAdmin_Concert') ) { $this->venue = GiglogAdmin_Venue::get($attrs->venue); } } + else { + $this->venue = NULL; + } } @@ -268,7 +273,12 @@ if ( !class_exists('GiglogAdmin_Concert') ) { $this->status = $new_status; } - public function roles() + /** + * Return the roles defined for this concert. + * + * @return array + */ + public function roles() : array { return $this->roles; } -- cgit v1.2.3