fixing homogenous check for attributes with non-numeric keys (#1057)

use reset() instead of trying to get zero array key
This commit is contained in:
Brett McBride 2023-06-28 16:25:27 +10:00 committed by GitHub
parent d6e0689604
commit cb45b4a75d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -121,7 +121,7 @@ final class AttributesBuilder implements AttributesBuilderInterface
if (count($value) <= 1) {
return true;
}
$type = gettype($value[0]);
$type = gettype(reset($value));
foreach ($value as $v) {
if (in_array(gettype($v), self::NUMERICS) && in_array($type, self::NUMERICS)) {
continue;

View File

@ -514,6 +514,7 @@ class SpanTest extends MockeryTestCase
[['foo', false]],
[['foo', 'bar', 3]],
[[5, 3.14, true]],
[['one' => 1, 'two' => true]],
];
}
@ -535,6 +536,7 @@ class SpanTest extends MockeryTestCase
'int and double' => [[3, 3.14159]],
'integers' => [[3, 1, 5]],
'doubles' => [[1.25, 3.11]],
'strings with non-numeric keys' => [['foo' => 'foo', 'bar' => 'bar']],
];
}