From 35bd198f479f242f5efcbac640403b1e22e0d180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Wed, 25 Sep 2024 14:24:30 +0200 Subject: [PATCH] fix return types of transformer functions --- includes/activitypub/transformer/class-events-manager.php | 4 ++-- includes/activitypub/transformer/class-gatherpress.php | 4 ++-- .../activitypub/transformer/class-the-events-calendar.php | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index 3e95fe0..e6053d4 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -125,14 +125,14 @@ final class Events_Manager extends Event_Transformer { /** * Get the end time from the events metadata. */ - public function get_end_time() { + public function get_end_time(): ?string { return null; } /** * Get the end time from the events metadata. */ - public function get_start_time() { + public function get_start_time(): string { $date_string = $this->em_event->event_start_date; $time_string = $this->em_event->event_start_time; $timezone_string = $this->em_event->event_timezone; diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php index 1bd9081..54488c8 100644 --- a/includes/activitypub/transformer/class-gatherpress.php +++ b/includes/activitypub/transformer/class-gatherpress.php @@ -97,14 +97,14 @@ final class GatherPress extends Event { /** * Get the end time from the event object. */ - protected function get_end_time() { + protected function get_end_time(): ?string { return $this->gp_event->get_datetime_end( 'Y-m-d\TH:i:s\Z' ); } /** * Get the end time from the event object. */ - protected function get_start_time() { + protected function get_start_time(): string { return $this->gp_event->get_datetime_start( 'Y-m-d\TH:i:s\Z' ); } diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php index 7707ca8..f03691d 100644 --- a/includes/activitypub/transformer/class-the-events-calendar.php +++ b/includes/activitypub/transformer/class-the-events-calendar.php @@ -64,7 +64,10 @@ final class The_Events_Calendar extends Event { /** * Get the end time from the event object. */ - protected function get_end_time() { + protected function get_end_time(): ?string { + if ( empty( $this->tribe_event->end_date ) ) { + return null; + } $date = date_create( $this->tribe_event->end_date, wp_timezone() ); return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() ); } @@ -72,7 +75,7 @@ final class The_Events_Calendar extends Event { /** * Get the end time from the event object. */ - protected function get_start_time() { + protected function get_start_time(): string { $date = date_create( $this->tribe_event->start_date, wp_timezone() ); return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() ); }