extraActions[spl_object_id($action)] = $action; } public function getInventory(Inventory $inventory) : TransactionBuilderInventory{ $id = spl_object_id($inventory); return $this->inventories[$id] ??= new TransactionBuilderInventory($inventory); } /** * @return InventoryAction[] */ public function generateActions() : array{ $actions = $this->extraActions; foreach($this->inventories as $inventory){ foreach($inventory->generateActions() as $action){ $actions[spl_object_id($action)] = $action; } } return $actions; } }