mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Throw exception on invalid parameters on Inventory addItem() and removeItem()
This commit is contained in:
parent
cf3f32fdae
commit
e5f28e0f7a
@ -236,6 +236,9 @@ abstract class BaseInventory implements Inventory{
|
|||||||
/** @var Item[] $slots */
|
/** @var Item[] $slots */
|
||||||
$itemSlots = [];
|
$itemSlots = [];
|
||||||
foreach($slots as $slot){
|
foreach($slots as $slot){
|
||||||
|
if(!($slot instanceof Item)){
|
||||||
|
throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot));
|
||||||
|
}
|
||||||
if($slot->getId() !== 0 and $slot->getCount() > 0){
|
if($slot->getId() !== 0 and $slot->getCount() > 0){
|
||||||
$itemSlots[] = clone $slot;
|
$itemSlots[] = clone $slot;
|
||||||
}
|
}
|
||||||
@ -293,6 +296,9 @@ abstract class BaseInventory implements Inventory{
|
|||||||
/** @var Item[] $slots */
|
/** @var Item[] $slots */
|
||||||
$itemSlots = [];
|
$itemSlots = [];
|
||||||
foreach($slots as $slot){
|
foreach($slots as $slot){
|
||||||
|
if(!($slot instanceof Item)){
|
||||||
|
throw new \InvalidArgumentException("Expected Item[], got ".gettype($slot));
|
||||||
|
}
|
||||||
if($slot->getId() !== 0 and $slot->getCount() > 0){
|
if($slot->getId() !== 0 and $slot->getCount() > 0){
|
||||||
$itemSlots[] = clone $slot;
|
$itemSlots[] = clone $slot;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user