-
Notifications
You must be signed in to change notification settings - Fork 81
Improve Following class documentation and method efficiency #2086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
- Remove unused Http import - Fix @see references to use proper namespace format (\Activitypub\follow) - Update return type documentation for follow() method to be more accurate - Optimize count methods to avoid unnecessary data retrieval by using minimal number parameter - Fix return type documentation for get_all_with_count to correctly reference 'following' instead of 'followers'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the Following
class by improving documentation quality and optimizing performance of count methods. The changes focus on cleaning up imports, fixing documentation references, and making count operations more efficient by fetching minimal data when only totals are needed.
- Remove unused
Activitypub\Http
import and fix namespace references in documentation - Optimize count methods to use
limit=1
instead of fetching all data when only counting - Improve method documentation with accurate return types and fix typos
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
* Data about the followings. | ||
* | ||
* @type \WP_Post[] $followers List of `Follower` objects. | ||
* @type int $total Total number of followers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly refers to 'followers' and 'Follower' objects in a Following class. This should be 'following' and 'Following' objects to match the class context.
* @type int $total Total number of followers. | |
* @type \WP_Post[] $following List of `Following` objects. | |
* @type int $total Total number of followings. |
Copilot uses AI. Check for mistakes.
* Data about the followings. | ||
* | ||
* @type \WP_Post[] $followers List of `Follower` objects. | ||
* @type int $total Total number of followers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation incorrectly refers to 'followers' when it should be 'following' to match the class context.
* @type int $total Total number of followers. | |
* @type \WP_Post[] $following List of `Following` objects. | |
* @type int $total Total number of following. |
Copilot uses AI. Check for mistakes.
* | ||
* @param \WP_Post|int $post The ID of the remote Actor. | ||
* @param int $user_id The ID of the WordPress User. | ||
* | ||
* @return \WP_Post|\WP_Error The ID of the Actor or a WP_Error. | ||
* @return int|false|\WP_Post|\WP_Error The Outbox ID or false on failure, the Actor post or a WP_Error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfefferle The possible return values of this method are a bit confusing. It's a WP_Error with an invalid actor, the outbox item ID on success and false on failure, and if we didn't get to adding it to the outbox, the actor post. Would it be possible to limit it to two types?
Adjusted the PHPDoc return types for the follow and unfollow functions to more accurately reflect their possible return values. This improves code documentation and helps with static analysis.
…ordpress-activitypub into fix/following-types
Fixes #
Proposed changes:
This PR improves the Following class with better documentation and more efficient method implementations:
Activitypub\Http
import@see
tags to use proper namespace format (\Activitypub\follow
instead ofActivitypub\follow
)follow()
method documentation to accurately reflect all possible return typescount_following
,count_pending
,count_all
) to use minimal parameters (limit=1) instead of fetching all data when only the total count is neededget_all_with_count()
to reference 'following' instead of 'followers'Other information:
Testing instructions:
Changelog entry
Changelog Entry Details
Significance
Type
Message
Improve Following class documentation and optimize count methods for better performance