Skip to content

Item: make setter methods fluent #6678

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

Merged
merged 2 commits into from
May 25, 2025
Merged

Conversation

SmallkingDev
Copy link
Contributor

@SmallkingDev SmallkingDev commented Apr 26, 2025

Make Item setter methods fluent

API Changes

  • Updated the return types of the following Item setter methods to $this:
    • setCanPlaceOn
    • setCanDestroy
    • setKeepOnDeath

Example:

Before:

$item = VanillaItems::DIAMOND_PICKAXE();
$item->setCanPlaceOn([]);
$item->setCanDestroy([]);
$item->setKeepOnDeath(true);

After:

$item = VanillaItems::DIAMOND_PICKAXE()
    ->setCanPlaceOn([])
    ->setCanDestroy([])
    ->setKeepOnDeath(true);

@SmallkingDev SmallkingDev requested a review from a team as a code owner April 26, 2025 14:48
@SmallkingDev SmallkingDev changed the base branch from stable to minor-next April 26, 2025 14:50
@dktapps
Copy link
Member

dktapps commented Apr 26, 2025

These changes are BC breaking for inheritors if they override any of these functions

@SmallkingDev
Copy link
Contributor Author

These changes are BC breaking for inheritors if they override any of these functions

The chance of someone doing this must be slim, but it's a valid concern.

@dktapps
Copy link
Member

dktapps commented Apr 26, 2025

Semver doesn't care about chances, objectively it is BC breaking, so it can't target a minor version.

@dktapps dktapps added Category: API Related to the plugin API BC break Breaks API compatibility Type: Enhancement Contributes features or other improvements to PocketMine-MP labels Apr 26, 2025
@dktapps dktapps changed the base branch from minor-next to major-next April 26, 2025 17:54
@ShockedPlot7560 ShockedPlot7560 merged commit 05eda88 into pmmp:major-next May 25, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC break Breaks API compatibility Category: API Related to the plugin API Type: Enhancement Contributes features or other improvements to PocketMine-MP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants