Skip to content

⚠️ !Breaking Change! Extend the generated models in the wrappers, remove getData() - #24

Merged
pavog merged 2 commits into
masterfrom
wrappers-extend-models
Oct 19, 2026
Merged

pavog merged 2 commits into
masterfrom
wrappers-extend-models

Conversation

@pavog

@pavog pavog commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

The wrappers Category, File, Game, GameVersionType and Mod now extend the generated models instead of wrapping them. All getters of the models can be called on the wrappers directly, so getData() is no longer needed:

// before
$name = $mod->getData()->getName();

// after
$name = $mod->getName();
Wrapper extends
Client\Category Model\Category
Client\File Model\File
Client\Game Model\Game
Client\GameVersionType Model\GameVersionType
Client\Mod Model\Mod

None of the wrapper methods has the same name as a getter of its model, so all existing methods keep their behaviour.

Breaking changes

  • getData() is removed from all wrappers. Call the getters on the wrapper instead, e.g. $mod->getName() instead of $mod->getData()->getName(). Wrappers can be passed wherever a model is expected, because they are instances of it.
  • The protected properties holding the model ($category, $file, $game, $gameVersion, $mod) are removed. This only affects classes that extend the wrappers.
  • The second constructor parameter is renamed to $data. This only affects code that creates wrappers with named arguments.

Tests and README

  • All uses of getData() are removed from the tests, the README and CurseForgeAPIClient::getCategory().
  • The unit tests check that the wrappers are instances of the models and that getData() returns the wrapper itself.
  • A new unit test checks that a wrapper is serialized to JSON like its model, without the client.

@pavog pavog changed the title extend the generated models in the wrappers ⚠️ !Breaking Change! Extend the generated models in the wrappers Oct 19, 2026
@pavog
pavog requested a review from JulianVennen October 19, 2026 11:39
@pavog pavog added this to the v4.0.0 milestone Oct 19, 2026

@JulianVennen JulianVennen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just remove getData completely instead of deprecating it? We have done the same for the modrinth client

@pavog pavog changed the title ⚠️ !Breaking Change! Extend the generated models in the wrappers ⚠️ !Breaking Change! Extend the generated models in the wrappers, remove getData() Oct 19, 2026
@pavog
pavog merged commit 92aeb5f into master Oct 19, 2026
5 checks passed
@pavog
pavog deleted the wrappers-extend-models branch October 19, 2026 11:54
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