-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
Problem
The Following::follow()
method and related follow()
function have overly complex return type signatures that make the code harder to understand and use reliably.
Current Return Types
Activitypub\Collection\Following::follow()
method:
\WP_Error
- when invalid actor or actor retrieval failsint|false
- fromadd_to_outbox()
when successfully adding follow activity\WP_Post
- when user is already following the actor
Activitypub\follow()
function:
@return int|false|\WP_Post|\WP_Error The Outbox ID or false on failure, the Actor post or a WP_Error.
Referenced Discussion
This issue was raised in PR #2086: #2086 (comment)
@obenland suggested: "Would it be possible to limit it to two types?" to simplify the return type complexity.
Proposed Solution
Standardize the return types to a maximum of two types (e.g., int|\WP_Error
or bool|\WP_Error
) to improve:
- Code predictability
- Error handling consistency
- Developer experience when using these methods
Code References
includes/functions.php:1556
-follow()
functionincludes/collection/class-following.php
-Following::follow()
methodincludes/functions.php:1471
-add_to_outbox()
function (returnsint|false
)
This refactoring would make the codebase more maintainable and reduce confusion about expected return types.
Metadata
Metadata
Assignees
Labels
No labels