Skip to content

Commit dcc5216

Browse files
authored
IBX-9727: Added missing type hints to collections framework (#555)
1 parent 2983b31 commit dcc5216

7 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/contracts/Collection/ArrayList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(array $items = [])
2727
parent::__construct(array_values($items));
2828
}
2929

30-
public function first()
30+
public function first(): mixed
3131
{
3232
if (($result = reset($this->items)) !== false) {
3333
return $result;
@@ -36,7 +36,7 @@ public function first()
3636
throw new OutOfBoundsException('Collection is empty');
3737
}
3838

39-
public function last()
39+
public function last(): mixed
4040
{
4141
if (($result = end($this->items)) !== false) {
4242
return $result;

src/contracts/Collection/ArrayMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class ArrayMap extends AbstractInMemoryCollection implements MapInterface
2323
{
24-
public function get($key)
24+
public function get($key): mixed
2525
{
2626
if (!$this->has($key)) {
2727
throw new OutOfBoundsException(sprintf("Collection does not contain element with key '%s'", $key));

src/contracts/Collection/ListInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface ListInterface extends CollectionInterface
2222
*
2323
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\OutOfBoundsException if collection is empty
2424
*/
25-
public function first();
25+
public function first(): mixed;
2626

2727
/**
2828
* Return last element of collection.
@@ -31,7 +31,7 @@ public function first();
3131
*
3232
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\OutOfBoundsException if collection is empty
3333
*/
34-
public function last();
34+
public function last(): mixed;
3535

3636
/**
3737
* @param TValue $value

src/contracts/Collection/MapInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface MapInterface extends CollectionInterface
2626
*
2727
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\OutOfBoundsException if map does not contain element with given key
2828
*/
29-
public function get($key);
29+
public function get($key): mixed;
3030

3131
/**
3232
* Returns true if the given key is defined within the map.

src/contracts/Collection/MutableArrayList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
*/
1818
class MutableArrayList extends ArrayList implements MutableListInterface
1919
{
20-
public function append($value): void
20+
public function append(mixed $value): void
2121
{
2222
$this->items[] = $value;
2323
}
2424

25-
public function prepend($value): void
25+
public function prepend(mixed $value): void
2626
{
2727
array_unshift($this->items, $value);
2828
}
2929

30-
public function remove($value): void
30+
public function remove(mixed $value): void
3131
{
3232
$idx = array_search($value, $this->items, true);
3333
if ($idx !== false) {

src/contracts/Collection/MutableListInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ interface MutableListInterface extends ListInterface
1818
/**
1919
* @param TValue $value
2020
*/
21-
public function append($value): void;
21+
public function append(mixed $value): void;
2222

2323
/**
2424
* @param TValue $value
2525
*/
26-
public function prepend($value): void;
26+
public function prepend(mixed $value): void;
2727

2828
/**
2929
* @param TValue $value
3030
*/
31-
public function remove($value): void;
31+
public function remove(mixed $value): void;
3232

3333
public function clear(): void;
3434
}

src/contracts/Collection/MutableMapInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ interface MutableMapInterface extends MapInterface
2020
* @param TKey $key
2121
* @param TValue $value
2222
*/
23-
public function set($key, $value): void;
23+
public function set(mixed $key, mixed $value): void;
2424

2525
/**
2626
* @param TKey $key
2727
*/
28-
public function unset($key): void;
28+
public function unset(mixed $key): void;
2929

3030
public function clear(): void;
3131
}

0 commit comments

Comments
 (0)