Skip to content

⚠️ !Breaking Change! Prefix wrapper methods that send a request with fetch - #38

Merged
pavog merged 2 commits into
masterfrom
fetch-methods
Oct 19, 2026
Merged

pavog merged 2 commits into
masterfrom
fetch-methods

Conversation

@pavog

@pavog pavog commented Oct 19, 2026

Copy link
Copy Markdown
Member

Depends on #37

The wrappers extend the generated models, so they have many getters that only return data, e.g. $project->getName(). Methods that send a request to the Hangar API, e.g. $project->getVersions(), looked the same. These methods are now prefixed with fetch:

// before
$versions = $project->getVersions();

// after
$versions = $project->fetchVersions();

Every fetch* method sends a request each time it is called, except fetchProject() of Version and ProjectPage (see below). This is also mentioned in the PHPDoc of each method.

Renamed methods

Wrapper before after
Project, CompactProject getVersions() fetchVersions()
Project, CompactProject getVersion() fetchVersion()
Project, CompactProject getWatchers() fetchWatchers()
Project, CompactProject getDailyStats() fetchDailyStats()
Project, CompactProject getStarGazers() fetchStarGazers()
Project, CompactProject getMembers() fetchMembers()
Project, CompactProject getOwner() fetchOwner()
Project, CompactProject getMainPage() fetchMainPage()
Project, CompactProject getPage() fetchPage()
CompactProject getProject() fetchProject()
User getWatchedProjects() fetchWatchedProjects()
User getStarredProjects() fetchStarredProjects()
User getPinnedProjects() fetchPinnedProjects()
User getProjects() fetchProjects()
Version getProject() fetchProject()
Version getDailyStats() fetchDailyStats()
ProjectPage getProject() fetchProject()

fetchProject() of Version and ProjectPage

These two methods keep the project once it is known, as before. They only send a request if the project is not known yet, e.g. a version returned by Project::fetchVersions() already knows its project. They are renamed anyway, because they can send a request.

Not renamed

  • Project::getSlug() and CompactProject::getSlug(), they do not send a request.
  • ProjectPage::save(), the name already says that it sends a request.
  • The methods of HangarAPIClient.

Breaking changes

The old method names are removed. They are not kept as deprecated aliases, because this is part of a major release.

Tests and README

  • The unit and integration tests use the new method names. The unit tests of the wrappers are renamed to testFetch*.
  • New unit tests for the methods that were not covered before: fetchDailyStats() of Project, CompactProject and Version, and fetchProject() of Version and ProjectPage. The fetchProject() tests check that the request is only sent once.
  • The README uses the new method names and explains the fetch prefix.

@pavog pavog added this to the v6.0.0 milestone Oct 19, 2026
@pavog
pavog requested a review from JulianVennen October 19, 2026 13:43
@pavog
pavog merged commit 0c6f8ff into master Oct 19, 2026
4 checks passed
@pavog
pavog deleted the fetch-methods branch October 19, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants