Skip to content

Commit 29d1d8a

Browse files
authored
Tree: Fix typehints.
1 parent fc7a812 commit 29d1d8a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/SelectboxTree.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class SelectboxTree
2828
* | | iMac
2929
* | Windows
3030
*
31-
* @param array<int, array{id: int|string, name: string, parentId: int|string|null}>|SelectboxItem[] $data
31+
* @param array<int, array{id: int|string, name: string, parent_id: int|string|null}>|SelectboxItem[] $data
3232
* @return array<int|string, string> (id => user haystack)
3333
*/
3434
public function process(array $data): array
@@ -47,7 +47,6 @@ public function process(array $data): array
4747
if ($this->nameFormatter !== null) {
4848
$categoryItem['name'] = $this->nameFormatter->format($categoryItem['name']);
4949
}
50-
5150
$categories[] = $categoryItem;
5251
}
5352

@@ -98,7 +97,7 @@ public function setNameFormatter(NameFormatter $nameFormatter): void
9897
* Build category tree to simple selectbox array.
9998
*
10099
* @param array<int, array{id: int|string, name: string, parent: int|string|null}>|null $categories
101-
* @return array<int, array{name: string, level: int}>
100+
* @return array<int|string, array{name: string, level: int}>
102101
*/
103102
private function serializeCategoriesToSelectbox(
104103
?array $categories,
@@ -116,13 +115,6 @@ private function serializeCategoriesToSelectbox(
116115

117116
$return = [];
118117
foreach ($categories as $catKey => $category) {
119-
if (
120-
array_key_exists('id', $category) === false
121-
|| array_key_exists('parent', $category) === false
122-
|| array_key_exists('name', $category) === false
123-
) {
124-
throw new \InvalidArgumentException('Category "' . $catKey . '" must contain keys "id", "parent" and "name".');
125-
}
126118
if ($category['parent'] === $parent) {
127119
if (isset($usedIds[$category['id']]) === false) {
128120
$return[$category['id']] = [

0 commit comments

Comments
 (0)