1 | <?php |
||
10 | trait ManagesCartItems |
||
11 | { |
||
12 | use HasItems; |
||
13 | |||
14 | /** |
||
15 | * Get the cart model instance. |
||
16 | * |
||
17 | * @return \Treestoneit\ShoppingCart\Models\Cart |
||
18 | */ |
||
19 | public function getModel(): Cart |
||
23 | |||
24 | /** |
||
25 | * Add an item to the cart. |
||
26 | * |
||
27 | * @param \Treestoneit\ShoppingCart\Buyable $buyable |
||
28 | * @param int $quantity |
||
29 | * @param array|null $options |
||
30 | * @return \Treestoneit\ShoppingCart\CartManager |
||
31 | */ |
||
32 | public function add(Buyable $buyable, int $quantity = 1, array $options = []): self |
||
70 | |||
71 | /** |
||
72 | * Change the quantity of an item in the cart. |
||
73 | * |
||
74 | * @param int $item |
||
75 | * @param int $quantity |
||
76 | * @return \Treestoneit\ShoppingCart\CartManager |
||
77 | * @throws \Exception |
||
78 | */ |
||
79 | public function update(int $item, int $quantity): self |
||
83 | |||
84 | /** |
||
85 | * Change the quantity of an item in the cart. |
||
86 | * |
||
87 | * @param int $item |
||
88 | * @param int $quantity |
||
89 | * @return \Treestoneit\ShoppingCart\CartManager |
||
90 | * @throws \Exception |
||
91 | */ |
||
92 | public function updateQuantity(int $item, int $quantity): self |
||
106 | |||
107 | /** |
||
108 | * Update the options of an item in the cart. |
||
109 | * |
||
110 | * @param int $item |
||
111 | * @param array $options |
||
112 | * @return \Treestoneit\ShoppingCart\CartManager |
||
113 | */ |
||
114 | public function updateOptions(int $item, array $options): self |
||
120 | |||
121 | /** |
||
122 | * Update an option of an item in the cart. |
||
123 | * |
||
124 | * @param int $item |
||
125 | * @param string $option |
||
126 | * @param $value |
||
127 | * @return \Treestoneit\ShoppingCart\CartManager |
||
128 | */ |
||
129 | public function updateOption(int $item, string $option, $value): self |
||
133 | |||
134 | /** |
||
135 | * Remove an item from the cart. |
||
136 | * |
||
137 | * @param int $item |
||
138 | * @return static |
||
139 | * @throws \Exception |
||
140 | */ |
||
141 | public function remove(int $item): self |
||
159 | |||
160 | /** |
||
161 | * Destroy the cart instance. |
||
162 | * |
||
163 | * @return static |
||
164 | */ |
||
165 | public function destroy() |
||
173 | |||
174 | /** |
||
175 | * Toggle the session key, and recalculate totals. |
||
176 | * |
||
177 | * @param \Treestoneit\ShoppingCart\Models\Cart|null $cart |
||
178 | * @return static |
||
179 | */ |
||
180 | public function refreshCart(Cart $cart = null): self |
||
200 | |||
201 | /** |
||
202 | * Persist the cart contents to the database. |
||
203 | * |
||
204 | * @return static |
||
205 | */ |
||
206 | protected function persist(): self |
||
212 | } |
||
213 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.