@@ -239,6 +239,7 @@ public function offsetExists($offset): bool
239239 #[\ReturnTypeWillChange]
240240 public function offsetGet ($ offset )
241241 {
242+ /** @var mixed $offset */
242243 if (\is_numeric ($ offset )) {
243244 if (!$ this ->numericOffsetExists ($ offset )) {
244245 throw new IndexError ("Index {$ offset } is out of range. " );
@@ -254,7 +255,7 @@ public function offsetGet($offset)
254255 return $ this ->subview ($ offset )->toArray ();
255256 }
256257
257- $ strOffset = is_scalar ($ offset ) ? strval ($ offset ) : gettype ($ offset );
258+ $ strOffset = \ is_scalar ($ offset ) ? \ strval ($ offset ) : \ gettype ($ offset );
258259 throw new KeyError ("Invalid key: \"{$ strOffset }\". " );
259260 }
260261
@@ -265,6 +266,7 @@ public function offsetGet($offset)
265266 */
266267 public function offsetSet ($ offset , $ value ): void
267268 {
269+ /** @var mixed $offset */
268270 if ($ this ->isReadonly ()) {
269271 throw new ReadonlyError ("Cannot modify a readonly view. " );
270272 }
@@ -290,7 +292,7 @@ public function offsetSet($offset, $value): void
290292 return ;
291293 }
292294
293- $ strOffset = is_scalar ($ offset ) ? strval ($ offset ) : gettype ($ offset );
295+ $ strOffset = \ is_scalar ($ offset ) ? \ strval ($ offset ) : \ gettype ($ offset );
294296 throw new KeyError ("Invalid key: \"{$ strOffset }\". " );
295297 }
296298
@@ -334,7 +336,7 @@ protected function convertIndex(int $i): int
334336 */
335337 private function numericOffsetExists ($ offset ): bool
336338 {
337- if (is_nan ($ offset ) || is_infinite ($ offset )) {
339+ if (! \is_string ( $ offset ) && \is_numeric ( $ offset ) && ( \ is_nan ($ offset ) || \ is_infinite ($ offset) )) {
338340 return false ;
339341 }
340342
0 commit comments