From c13230ac6fe11471fe6633627dd07956f44731b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Wed, 25 Sep 2024 14:30:37 +0200 Subject: [PATCH] fix more function return types in transformers --- .../transformer/class-events-manager.php | 4 ++-- .../activitypub/transformer/class-gatherpress.php | 2 +- .../transformer/class-vs-event-list.php | 14 +++----------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index e6053d4..04a8ecb 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -89,7 +89,7 @@ final class Events_Manager extends Event_Transformer { * * @return array The Place. */ - public function get_location() { + public function get_location(): ?Place { if ( 'url' === $this->em_event->event_location_type ) { return null; } @@ -181,7 +181,7 @@ final class Events_Manager extends Event_Transformer { /** * Hardcoded function for generating a summary. */ - public function get_summary() { + public function get_summary(): ?string { if ( $this->em_event->post_excerpt ) { $excerpt = $this->em_event->post_excerpt; } else { diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php index 54488c8..a234af3 100644 --- a/includes/activitypub/transformer/class-gatherpress.php +++ b/includes/activitypub/transformer/class-gatherpress.php @@ -81,7 +81,7 @@ final class GatherPress extends Event { * * @return Place|null The place objector null if not place set. */ - public function get_location(): Place|null { + public function get_location(): ?Place { $address = $this->gp_venue['full_address']; if ( $address ) { $place = new Place(); diff --git a/includes/activitypub/transformer/class-vs-event-list.php b/includes/activitypub/transformer/class-vs-event-list.php index 81d36e8..adce99e 100644 --- a/includes/activitypub/transformer/class-vs-event-list.php +++ b/includes/activitypub/transformer/class-vs-event-list.php @@ -31,17 +31,6 @@ final class VS_Event_List extends Event_Transformer { */ protected $ap_object; - /** - * Returns the ActivityStreams 2.0 Object-Type for an Event. - * - * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event - * @since 1.0.0 - * @return string The Event Object-Type. - */ - protected function get_type(): string { - return 'Event'; - } - /** * Get the event location. * @@ -68,6 +57,9 @@ final class VS_Event_List extends Event_Transformer { return null; } $end_time = get_post_meta( $this->wp_object->ID, 'event-date', true ); + if ( is_null( $end_time ) || empty( $end_time ) || 'no' === $end_time ) { + return null; + } return $end_time ? \gmdate( 'Y-m-d\TH:i:s\Z', $end_time ) : null; }