Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@
return $key($array, $default);
}

if (is_array($array) && is_scalar($key)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use common is_array($array) check with the following condition instead

return array_key_exists($key, $array) ? $array[$key] : $default;

Check failure on line 216 in src/ArrayHelper.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.3-ubuntu-latest

PossiblyInvalidArgument

src/ArrayHelper.php:216:37: PossiblyInvalidArgument: Argument 1 of array_key_exists expects array-key, but possibly different type float|int|string provided (see https://psalm.dev/092)

Check failure on line 216 in src/ArrayHelper.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.1-ubuntu-latest

PossiblyInvalidArgument

src/ArrayHelper.php:216:37: PossiblyInvalidArgument: Argument 1 of array_key_exists expects array-key, but possibly different type float|int|string provided (see https://psalm.dev/092)

Check failure on line 216 in src/ArrayHelper.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.2-ubuntu-latest

PossiblyInvalidArgument

src/ArrayHelper.php:216:37: PossiblyInvalidArgument: Argument 1 of array_key_exists expects array-key, but possibly different type float|int|string provided (see https://psalm.dev/092)

Check failure on line 216 in src/ArrayHelper.php

View workflow job for this annotation

GitHub Actions / psalm / PHP 8.4-ubuntu-latest

PossiblyInvalidArgument

src/ArrayHelper.php:216:37: PossiblyInvalidArgument: Argument 1 of array_key_exists expects array-key, but possibly different type float|int|string provided (see https://psalm.dev/092)
}

if (is_array($key)) {
if (empty($key)) {
return $default;
Expand Down
Loading