@@ -52,14 +52,14 @@ final class IndexedCollector implements CollectorInterface, \ArrayAccess, \Itera
5252 /**
5353 * Index of values with keys of scalar type.
5454 *
55- * @var array<TKey , list<TValue>>
55+ * @var array<scalar , list<TValue>>
5656 */
5757 private array $ scalarIndex = [];
5858
5959 /**
6060 * Index of values with keys of object type.
6161 *
62- * @var \SplObjectStorage<TKey& object, list<TValue>>
62+ * @var \SplObjectStorage<object, list<TValue>>
6363 */
6464 private \SplObjectStorage $ objectIndex ;
6565
@@ -81,9 +81,9 @@ public function __construct(
8181 foreach ($ this ->source as $ key => $ value ) {
8282 $ this ->collected [] = [$ key , $ value ];
8383
84- if (\is_string ( $ key ) || \is_int ($ key )) {
85- $ this ->scalarIndex [$ key ] = $ this ->scalarIndex [$ key ] ?? [];
86- $ this ->scalarIndex [$ key ][] = $ value ;
84+ if (\is_scalar ($ key )) {
85+ $ this ->scalarIndex [$ key ] = $ this ->scalarIndex [$ key ] ?? []; // @phpstan-ignore-line
86+ $ this ->scalarIndex [$ key ][] = $ value ; // @phpstan-ignore-line
8787 continue ;
8888 }
8989
@@ -115,7 +115,7 @@ public function getIterator(): \Traversable
115115 public function offsetExists (mixed $ offset ): bool
116116 {
117117 return match (true ) {
118- \is_string ($ offset ) || \is_int ( $ offset ) => \array_key_exists ($ offset , $ this ->scalarIndex ),
118+ \is_scalar ($ offset ) => \array_key_exists ($ offset , $ this ->scalarIndex ), // @phpstan-ignore-line
119119 \is_object ($ offset ) => $ this ->objectIndex ->contains ($ offset ),
120120 default => throw new UnsupportedException ('Only object and scalar keys are supported. ' ),
121121 };
@@ -135,7 +135,7 @@ public function offsetGet(mixed $offset): mixed
135135 }
136136
137137 return match (true ) {
138- \is_string ($ offset ) || \is_int ( $ offset ) => $ this ->scalarIndex [$ offset ],
138+ \is_scalar ($ offset ) => $ this ->scalarIndex [$ offset ], // @phpstan-ignore-line
139139 \is_object ($ offset ) => $ this ->objectIndex [$ offset ],
140140 default => throw new UnsupportedException ('Only object and scalar keys are supported. ' ),
141141 };
0 commit comments