summaryrefslogtreecommitdiffstats
path: root/includes/concert.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-09-02 09:10:19 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-09-02 09:10:19 +0200
commit3668e685566bed2d3623a3cd276d93f79319a008 (patch)
tree614f817ad0314b5b446addb8175d31ac149f8b33 /includes/concert.php
parentecd1eb7848d7657267a55cbee03eb2f90a1ba1b7 (diff)
downloadgigologadmin-3668e685566bed2d3623a3cd276d93f79319a008.tar.gz
gigologadmin-3668e685566bed2d3623a3cd276d93f79319a008.tar.bz2
gigologadmin-3668e685566bed2d3623a3cd276d93f79319a008.zip
psalm: Add type info to attrs and constructor for Concert.
Also make sure we explicitly set the venue attribute in the constructor.
Diffstat (limited to 'includes/concert.php')
-rw-r--r--includes/concert.php26
1 files changed, 18 insertions, 8 deletions
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<string, string>
+ */
+ public function roles() : array
{
return $this->roles;
}