Item: make setter methods fluent (#6678)

- `Item::clearCustomBlockData` previously, the instance was returned, but the return type has been changed
- `Item::setCanPlaceOn`, `Item::setCanDestroy` and `Item::setKeepOnDeath` now return `$this`
This commit is contained in:
João 2025-05-25 09:35:26 +01:00 committed by GitHub
parent 18b6b1742c
commit 05eda887b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -125,7 +125,7 @@ class Item implements \JsonSerializable{
/** /**
* @return $this * @return $this
*/ */
public function clearCustomBlockData(){ public function clearCustomBlockData() : Item{
$this->blockEntityTag = null; $this->blockEntityTag = null;
return $this; return $this;
} }
@ -202,11 +202,12 @@ class Item implements \JsonSerializable{
/** /**
* @param string[] $canPlaceOn * @param string[] $canPlaceOn
*/ */
public function setCanPlaceOn(array $canPlaceOn) : void{ public function setCanPlaceOn(array $canPlaceOn) : Item{
$this->canPlaceOn = []; $this->canPlaceOn = [];
foreach($canPlaceOn as $value){ foreach($canPlaceOn as $value){
$this->canPlaceOn[$value] = $value; $this->canPlaceOn[$value] = $value;
} }
return $this;
} }
/** /**
@ -220,11 +221,12 @@ class Item implements \JsonSerializable{
/** /**
* @param string[] $canDestroy * @param string[] $canDestroy
*/ */
public function setCanDestroy(array $canDestroy) : void{ public function setCanDestroy(array $canDestroy) : Item{
$this->canDestroy = []; $this->canDestroy = [];
foreach($canDestroy as $value){ foreach($canDestroy as $value){
$this->canDestroy[$value] = $value; $this->canDestroy[$value] = $value;
} }
return $this;
} }
/** /**
@ -234,8 +236,9 @@ class Item implements \JsonSerializable{
return $this->keepOnDeath; return $this->keepOnDeath;
} }
public function setKeepOnDeath(bool $keepOnDeath) : void{ public function setKeepOnDeath(bool $keepOnDeath) : Item{
$this->keepOnDeath = $keepOnDeath; $this->keepOnDeath = $keepOnDeath;
return $this;
} }
/** /**