diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2021-09-02 09:10:19 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2021-09-02 09:10:19 +0200 |
commit | 3668e685566bed2d3623a3cd276d93f79319a008 (patch) | |
tree | 614f817ad0314b5b446addb8175d31ac149f8b33 | |
parent | ecd1eb7848d7657267a55cbee03eb2f90a1ba1b7 (diff) | |
download | gigologadmin-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.
-rw-r--r-- | includes/concert.php | 26 |
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; } |