Skip to content

Commit 0b19fa1

Browse files
committed
Update return type
1 parent 18697f4 commit 0b19fa1

File tree

7 files changed

+22
-32
lines changed

7 files changed

+22
-32
lines changed

phpstan.neon.dist

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,3 @@ parameters:
55
reportUnmatchedIgnoredErrors: false
66
checkGenericClassInNonGenericObjectType: false
77
checkMissingIterableValueType: false
8-
ignoreErrors:
9-
- '#Method Lenius\\Basket\\Storage\\Session::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
10-
- '#Method Lenius\\Basket\\Storage\\Runtime::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
11-
- '#Method Lenius\\Basket\\StorageInterface::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
12-
- '#Method Lenius\\Basket\\ItemInterface::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
13-
- '#Method Lenius\\Basket\\IdentifierInterface::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
14-
- '#Method Lenius\\Basket\\Item::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
15-
- '#Method Lenius\\Basket\\Basket::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
16-
- '#Method Lenius\\Basket\\Identifier\\Cookie::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'
17-
- '#Method Lenius\\Basket\\Identifier\\Runtime::[a-zA-Z0-9\\_]+\(\) has no return typehint specified.#'

src/Basket.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function insert(ItemInterface $item): string
113113
* @param mixed $key The key to update, or an array of key-value pairs
114114
* @param mixed $value The value to set $key to
115115
*/
116-
public function update(string $itemIdentifier, $key, $value = null)
116+
public function update(string $itemIdentifier, $key, $value = null): void
117117
{
118118
/** @var Item $item */
119119
foreach ($this->contents() as $item) {
@@ -130,15 +130,15 @@ public function update(string $itemIdentifier, $key, $value = null)
130130
*
131131
* @param string $identifier Unique item identifier
132132
*/
133-
public function remove(string $identifier)
133+
public function remove(string $identifier): void
134134
{
135135
$this->store->remove($identifier);
136136
}
137137

138138
/**
139139
* Destroy/empty the basket.
140140
*/
141-
public function destroy()
141+
public function destroy(): void
142142
{
143143
$this->store->destroy();
144144
}
@@ -258,7 +258,7 @@ public function totalItems($unique = false): int
258258
*
259259
* @param string $identifier
260260
*/
261-
public function setIdentifier(string $identifier)
261+
public function setIdentifier(string $identifier): void
262262
{
263263
$this->store->setIdentifier($identifier);
264264
}
@@ -288,7 +288,7 @@ protected function createItemIdentifier(ItemInterface $item): string
288288
* Check if a basket item has the required parameters.
289289
* @param ItemInterface $item
290290
*/
291-
protected function checkArgs(ItemInterface $item)
291+
protected function checkArgs(ItemInterface $item): void
292292
{
293293
foreach ($this->requiredParams as $param) {
294294
if (! array_key_exists($param, $item->toArray())) {

src/Item.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function __construct(array $item)
5959
*
6060
* @param string $identifier
6161
*/
62-
public function setIdentifier(string $identifier)
62+
public function setIdentifier(string $identifier): void
6363
{
6464
$this->identifier = $identifier;
6565
}
@@ -82,7 +82,7 @@ public function __get(string $param)
8282
* @param mixed $param The key to set
8383
* @param mixed $value The value to set $param to
8484
*/
85-
public function __set($param, $value)
85+
public function __set($param, $value): void
8686
{
8787
$this->data[$param] = $value;
8888

@@ -186,7 +186,7 @@ public function single($includeTax = true): float
186186
* @param mixed $key The array key to update, or an array of key-value pairs to update
187187
* @param mixed $value
188188
*/
189-
public function update($key, $value = null)
189+
public function update($key, $value = null): void
190190
{
191191
if ($key instanceof ItemInterface) {
192192
foreach ($key->toArray() as $updateKey => $updateValue) {

src/ItemInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface ItemInterface
3333
/**
3434
* @param string $identifier
3535
*/
36-
public function setIdentifier(string $identifier);
36+
public function setIdentifier(string $identifier): void;
3737

3838
/**
3939
* Return the total tax for this item.
@@ -73,7 +73,7 @@ public function single($includeTax = true): float;
7373
* @param mixed $key The array key to update, or an array of key-value pairs to update
7474
* @param mixed $value
7575
*/
76-
public function update($key, $value = null);
76+
public function update($key, $value = null): void;
7777

7878
/**
7979
* Check if this item has options.
@@ -95,7 +95,7 @@ public function toArray(): array;
9595
* @param mixed $param
9696
* @param mixed $value
9797
*/
98-
public function __set($param, $value);
98+
public function __set($param, $value): void;
9999

100100
/**
101101
* Return the value of protected methods.

src/Storage/Runtime.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Runtime implements StorageInterface
4343
*
4444
* @param ItemInterface $item The item to insert or update
4545
*/
46-
public function insertUpdate(ItemInterface $item)
46+
public function insertUpdate(ItemInterface $item): void
4747
{
4848
static::$cart[$this->id][$item->identifier] = $item;
4949
}
@@ -135,15 +135,15 @@ public function find(string $id)
135135
*
136136
* @param string $id
137137
*/
138-
public function remove(string $id)
138+
public function remove(string $id): void
139139
{
140140
unset(static::$cart[$this->id][$id]);
141141
}
142142

143143
/**
144144
* Destroy the cart.
145145
*/
146-
public function destroy()
146+
public function destroy(): void
147147
{
148148
static::$cart[$this->id] = [];
149149
}
@@ -155,7 +155,7 @@ public function destroy()
155155
*
156156
* @internal param string $identifier
157157
*/
158-
public function setIdentifier(string $identifier)
158+
public function setIdentifier(string $identifier): void
159159
{
160160
$this->id = $identifier;
161161

@@ -177,7 +177,7 @@ public function getIdentifier(): string
177177
/**
178178
* Restore the cart.
179179
*/
180-
public function restore()
180+
public function restore(): void
181181
{
182182
if (isset($_SESSION['cart'])) {
183183
static::$cart = unserialize($_SESSION['cart']);

src/Storage/Session.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Session extends Runtime implements StorageInterface
3030
/**
3131
* The Session store constructor.
3232
*/
33-
public function restore()
33+
public function restore(): void
3434
{
3535
session_id() || session_start();
3636

src/StorageInterface.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ interface StorageInterface
3030
*
3131
* @param ItemInterface $item The item to insert or update
3232
*/
33-
public function insertUpdate(ItemInterface $item);
33+
public function insertUpdate(ItemInterface $item): void;
3434

3535
/**
3636
* Retrieve the cart data.
@@ -73,24 +73,24 @@ public function find(string $id);
7373
*
7474
* @param string $id
7575
*/
76-
public function remove(string $id);
76+
public function remove(string $id): void;
7777

7878
/**
7979
* Destroy the cart.
8080
*/
81-
public function destroy();
81+
public function destroy(): void;
8282

8383
/**
8484
* Restore the cart.
8585
*/
86-
public function restore();
86+
public function restore(): void;
8787

8888
/**
8989
* Set the cart identifier.
9090
*
9191
* @param string $identifier
9292
*/
93-
public function setIdentifier(string $identifier);
93+
public function setIdentifier(string $identifier): void;
9494

9595
/**
9696
* Return the current cart identifier.

0 commit comments

Comments
 (0)