22declare(strict_types=1);
38 private ?\Closure $onSlotChange,
39 private ?\Closure $onContentChange
41 if($onSlotChange !==
null){
44 if($onContentChange !==
null){
52 public static function onAnyChange(\Closure $onChange) : self{
54 static function(
Inventory $inventory, int $unused,
Item $unusedB) use ($onChange) : void{
55 $onChange($inventory);
57 static function(
Inventory $inventory, array $unused) use ($onChange) :
void{
58 $onChange($inventory);
63 public function onSlotChange(Inventory $inventory,
int $slot, Item $oldItem) : void{
64 if($this->onSlotChange !== null){
65 ($this->onSlotChange)($inventory, $slot, $oldItem);
73 if($this->onContentChange !== null){
74 ($this->onContentChange)($inventory, $oldContents);
onContentChange(Inventory $inventory, array $oldContents)
__construct(private ?\Closure $onSlotChange, private ?\Closure $onContentChange)
static onAnyChange(\Closure $onChange)
static validateCallableSignature(callable|CallbackType $signature, callable $subject)