Skip to content

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

Merged
pavog merged 1 commit into
masterfrom
fetch-methods
Oct 19, 2026
Merged

pavog merged 1 commit into
masterfrom
fetch-methods

Conversation

@pavog

@pavog pavog commented Oct 19, 2026

Copy link
Copy Markdown
Member

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

// before
$game = $mod->getGame();

// after
$game = $mod->fetchGame();

Every fetch* method sends a request each time it is called. The result is not cached. This is also mentioned in the PHPDoc of each method.

Rename methods

Wrapper before after
Category getMods() fetchMods()
Category getGame() fetchGame()
File getServerPack() fetchServerPack()
File getChangelog() fetchChangelog()
File getMod() fetchMod()
Game getVersionTypes() fetchVersionTypes()
Game getVersions() fetchVersions()
Game getGameVersionsByType() fetchGameVersionsByType()
Game getCategories() fetchCategories()
Game getFeaturedMods() fetchFeaturedMods()
GameVersionType getVersions() fetchVersions()
GameVersionType getGame() fetchGame()
Mod getDescription() fetchDescription()
Mod getFiles() fetchFiles()
Mod getGame() fetchGame()
Mod getCategoryClass() fetchCategoryClass()
Mod getMainFile() fetchMainFile()
Mod getFile() fetchFile()

Not renamed

  • Game::searchMods(), the name already says that it sends a request.
  • Mod::getPrimaryCategory(), it does not send a request.
  • The methods of CurseForgeAPIClient.

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

  • New unit tests for every wrapper (CategoryTest, FileTest, GameTest, GameVersionTypeTest, ModTest) check the request that each fetch* method sends. The wrapper methods were not covered by unit tests before.
  • The integration tests use the new method names.
  • The README has a new “Wrappers” section and uses the new method names. It also fixes the example for the versions of a version type, which called the non-existent method getGameVersionTypeVersions() instead of getGameVersionsByType().

@pavog
pavog requested a review from JulianVennen October 19, 2026 12:01
@pavog
pavog merged commit 48565bb into master Oct 19, 2026
4 checks passed
@pavog
pavog deleted the fetch-methods branch October 19, 2026 12:12
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